From 88eb3b1670ac3989e6549bd8870f482ce357c979 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 31 Mar 2010 11:41:07 +1000 Subject: Allow attributes to be bound after a QGLShaderProgram is linked. Task-number: QTBUG-9450 Reviewed-by: Sarah Smith --- src/opengl/qglshaderprogram.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 79484fa..bbfc2d5 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -969,17 +969,18 @@ GLuint QGLShaderProgram::programId() const Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically. + When this function is called after the program has been linked, + the program will need to be relinked for the change to take effect. + \sa attributeLocation() */ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) { Q_D(QGLShaderProgram); - if (!d->linked) { - glBindAttribLocation(d->programGuard.id(), location, name); - } else { - qWarning() << "QGLShaderProgram::bindAttributeLocation(" << name - << "): cannot bind after shader program is linked"; - } + if (!init()) + return; + glBindAttribLocation(d->programGuard.id(), location, name); + d->linked = false; // Program needs to be relinked. } /*! @@ -990,6 +991,9 @@ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically. + When this function is called after the program has been linked, + the program will need to be relinked for the change to take effect. + \sa attributeLocation() */ void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location) @@ -1005,6 +1009,9 @@ void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int locatio Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically. + When this function is called after the program has been linked, + the program will need to be relinked for the change to take effect. + \sa attributeLocation() */ void QGLShaderProgram::bindAttributeLocation(const QString& name, int location) -- cgit v0.12