summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-10-25 22:14:26 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-10-25 22:14:26 (GMT)
commitf78d8cce8fc78b0233237e5d1414a1fd4b23e37a (patch)
tree46b1157960d411c12196247f7b5931c402df806f
parent48df46cd38e69fed9454d97eeaf8cf0c0489acfa (diff)
downloadQt-f78d8cce8fc78b0233237e5d1414a1fd4b23e37a.zip
Qt-f78d8cce8fc78b0233237e5d1414a1fd4b23e37a.tar.gz
Qt-f78d8cce8fc78b0233237e5d1414a1fd4b23e37a.tar.bz2
Issue a warning if bindAttributeLocation() is used after shaders linked
Attribute locations must be bound before a shader program is linked according to the GLSL specification. Issue a warning to the user if they do it in the wrong order, which should help to isolate hard to find bugs much quicker. Reviewed-by: trustme
-rw-r--r--src/opengl/qglshaderprogram.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index dfa6c40..34114e4 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -1265,7 +1265,12 @@ GLuint QGLShaderProgram::programId() const
*/
void QGLShaderProgram::bindAttributeLocation(const char *name, int location)
{
- glBindAttribLocation(d->programGuard.id(), location, name);
+ if (!d->linked) {
+ glBindAttribLocation(d->programGuard.id(), location, name);
+ } else {
+ qWarning() << "QGLShaderProgram::bindAttributeLocation(" << name
+ << "): cannot bind after shader program is linked";
+ }
}
/*!
@@ -1280,7 +1285,7 @@ void QGLShaderProgram::bindAttributeLocation(const char *name, int location)
*/
void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location)
{
- glBindAttribLocation(d->programGuard.id(), location, name.constData());
+ bindAttributeLocation(name.constData(), location);
}
/*!
@@ -1295,7 +1300,7 @@ void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int locatio
*/
void QGLShaderProgram::bindAttributeLocation(const QString& name, int location)
{
- glBindAttribLocation(d->programGuard.id(), location, name.toLatin1().constData());
+ bindAttributeLocation(name.toLatin1().constData(), location);
}
/*!