Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/opengl/qglshaderprogram.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    106106
    107107    \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 2
     108
     109    \section1 Binary shaders and programs
     110
     111    Binary shaders may be specified using \c{glShaderBinary()} on
     112    the return value from QGLShader::shaderId().  The QGLShader instance
     113    containing the binary can then be added to the shader program with
     114    addShader() and linked in the usual fashion with link().
     115
     116    Binary programs may be specified using \c{glProgramBinaryOES()}
     117    on the return value from programId().  Then the application should
     118    call link(), which will notice that the program has already been
     119    specified and linked, allowing other operations to be performed
     120    on the shader program.
    108121
    109122    \sa QGLShader
     
    633646            return false;
    634647        }
    635         if (!shader->d_func()->compiled)
    636             return false;
    637648        if (!shader->d_func()->shaderGuard.id())
    638649            return false;
     
    821832    if (!program)
    822833        return false;
     834    GLint value;
     835    if (d->shaders.isEmpty()) {
     836        // If there are no explicit shaders, then it is possible that the
     837        // application added a program binary with glProgramBinaryOES(),
     838        // or otherwise populated the shaders itself.  Check to see if the
     839        // program is already linked and bail out if so.
     840        value = 0;
     841        glGetProgramiv(program, GL_LINK_STATUS, &value);
     842        d->linked = (value != 0);
     843        if (d->linked)
     844            return true;
     845    }
    823846    glLinkProgram(program);
    824     GLint value = 0;
     847    value = 0;
    825848    glGetProgramiv(program, GL_LINK_STATUS, &value);
    826849    d->linked = (value != 0);
     
    929952{
    930953    Q_D(const QGLShaderProgram);
     954    GLuint id = d->programGuard.id();
     955    if (id)
     956        return id;
     957
     958    // Create the identifier if we don't have one yet.  This is for
     959    // applications that want to create the attached shader configuration
     960    // themselves, particularly those using program binaries.
     961    if (!const_cast<QGLShaderProgram *>(this)->init())
     962        return 0;
    931963    return d->programGuard.id();
    932964}
Note: See TracChangeset for help on using the changeset viewer.