From f78d8cce8fc78b0233237e5d1414a1fd4b23e37a Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 08:14:26 +1000 Subject: 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 --- src/opengl/qglshaderprogram.cpp | 11 ++++++++--- 1 file 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); } /*! -- cgit v0.12