From 0d6104d763f4cb32ac6117b3f951afcb73fc50e6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 10:33:38 +1000 Subject: Make compile on X11 systems where qreal == float Reviewed-by: Sarah Smith --- src/gui/text/qfontdatabase_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index b582e4a..f184811 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -1456,7 +1456,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD slant_value = FC_SLANT_OBLIQUE; FcPatternAddInteger(pattern, FC_SLANT, slant_value); - double size_value = qMax(1., request.pixelSize); + double size_value = qMax(qreal(1.), request.pixelSize); FcPatternAddDouble(pattern, FC_PIXEL_SIZE, size_value); int stretch = request.stretch; -- cgit v0.12 From 1a299a9631a2d1b4e07cedfece7af5318a766fe6 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 10:36:45 +1000 Subject: Optimize QGraphicsRotation's use of QMatrix4x4 Previous code was creating a full 3D rotation matrix and then projecting back to 2D. This change combines the two steps into one to avoid calculating matrix components that will be dropped. Reviewed-by: Sarah Smith --- src/gui/graphicsview/qgraphicstransform.cpp | 4 +- src/gui/math3d/qmatrix4x4.cpp | 108 ++++++++++++++++++++- src/gui/math3d/qmatrix4x4.h | 4 + .../qgraphicstransform/tst_qgraphicstransform.cpp | 69 ++++++++++++- 4 files changed, 179 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index a0b5493..93dc196 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -547,9 +547,7 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const return; matrix->translate(d->origin); - QMatrix4x4 m; - m.rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); - *matrix *= m.toTransform(1024.0f); // Project back to 2D. + matrix->projectedRotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); matrix->translate(-d->origin); } diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 00e8f15..fa3826f 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE \sa QVector3D, QGenericMatrix */ +static const qreal inv_dist_to_plane = 1. / 1024.; + /*! \fn QMatrix4x4::QMatrix4x4() @@ -1103,6 +1105,110 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z) return *this; } +/*! + \internal +*/ +QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z) +{ + // Used by QGraphicsRotation::applyTo() to perform a rotation + // and projection back to 2D in a single step. + if (angle == 0.0f) + return *this; + QMatrix4x4 m(1); // The "1" says to not load the identity. + qreal c, s, ic; + if (angle == 90.0f || angle == -270.0f) { + s = 1.0f; + c = 0.0f; + } else if (angle == -90.0f || angle == 270.0f) { + s = -1.0f; + c = 0.0f; + } else if (angle == 180.0f || angle == -180.0f) { + s = 0.0f; + c = -1.0f; + } else { + qreal a = angle * M_PI / 180.0f; + c = qCos(a); + s = qSin(a); + } + bool quick = false; + if (x == 0.0f) { + if (y == 0.0f) { + if (z != 0.0f) { + // Rotate around the Z axis. + m.setIdentity(); + m.m[0][0] = c; + m.m[1][1] = c; + if (z < 0.0f) { + m.m[1][0] = s; + m.m[0][1] = -s; + } else { + m.m[1][0] = -s; + m.m[0][1] = s; + } + m.flagBits = General; + quick = true; + } + } else if (z == 0.0f) { + // Rotate around the Y axis. + m.setIdentity(); + m.m[0][0] = c; + m.m[2][2] = 1.0f; + if (y < 0.0f) { + m.m[0][3] = -s * inv_dist_to_plane; + } else { + m.m[0][3] = s * inv_dist_to_plane; + } + m.flagBits = General; + quick = true; + } + } else if (y == 0.0f && z == 0.0f) { + // Rotate around the X axis. + m.setIdentity(); + m.m[1][1] = c; + m.m[2][2] = 1.0f; + if (x < 0.0f) { + m.m[1][3] = s * inv_dist_to_plane; + } else { + m.m[1][3] = -s * inv_dist_to_plane; + } + m.flagBits = General; + quick = true; + } + if (!quick) { + qreal len = x * x + y * y + z * z; + if (!qFuzzyIsNull(len - 1.0f) && !qFuzzyIsNull(len)) { + len = qSqrt(len); + x /= len; + y /= len; + z /= len; + } + ic = 1.0f - c; + m.m[0][0] = x * x * ic + c; + m.m[1][0] = x * y * ic - z * s; + m.m[2][0] = 0.0f; + m.m[3][0] = 0.0f; + m.m[0][1] = y * x * ic + z * s; + m.m[1][1] = y * y * ic + c; + m.m[2][1] = 0.0f; + m.m[3][1] = 0.0f; + m.m[0][2] = 0.0f; + m.m[1][2] = 0.0f; + m.m[2][2] = 1.0f; + m.m[3][2] = 0.0f; + m.m[0][3] = (x * z * ic - y * s) * -inv_dist_to_plane; + m.m[1][3] = (y * z * ic + x * s) * -inv_dist_to_plane; + m.m[2][3] = 0.0f; + m.m[3][3] = 1.0f; + } + int flags = flagBits; + *this *= m; + if (flags != Identity) + flagBits = flags | Rotation; + else + flagBits = Rotation; + return *this; +} + #ifndef QT_NO_VECTOR4D /*! @@ -1448,8 +1554,6 @@ QTransform QMatrix4x4::toTransform() const m[3][0], m[3][1], m[3][3]); } -static const qreal inv_dist_to_plane = 1. / 1024.; - /*! Returns the conventional Qt 2D transformation matrix that corresponds to this matrix. diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 42d992e..ba74b89 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -207,6 +207,10 @@ private: QMatrix4x4(int) { flagBits = General; } QMatrix4x4 orthonormalInverse() const; + + QMatrix4x4& projectedRotate(qreal angle, qreal x, qreal y, qreal z); + + friend class QGraphicsRotation; }; inline QMatrix4x4::QMatrix4x4 diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index eb5c099..d8ab06e 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -59,6 +59,8 @@ private slots: void rotation(); void rotation3d_data(); void rotation3d(); + void rotation3dArbitraryAxis_data(); + void rotation3dArbitraryAxis(); }; @@ -88,7 +90,7 @@ static QTransform transform2D(const QGraphicsTransform& t) { QMatrix4x4 m; t.applyTo(&m); - return m.toTransform(0); + return m.toTransform(); } void tst_QGraphicsTransform::scale() @@ -255,6 +257,19 @@ void tst_QGraphicsTransform::rotation3d() QVERIFY(fuzzyCompare(transform2D(rotation), expected)); + // Check that "rotation" produces the 4x4 form of the 3x3 matrix. + // i.e. third row and column are 0 0 1 0. + t.setIdentity(); + rotation.applyTo(&t); + QMatrix4x4 r(expected); + if (sizeof(qreal) == sizeof(float) && angle == 268) { + // This test fails, on only this angle, when qreal == float + // because the deg2rad value in QTransform is not accurate + // enough to match what QMatrix4x4 is doing. + } else { + QVERIFY(qFuzzyCompare(t, r)); + } + //now let's check that a null vector will not change the transform rotation.setAxis(QVector3D(0, 0, 0)); rotation.setOrigin(QVector3D(10, 10, 0)); @@ -276,6 +291,58 @@ void tst_QGraphicsTransform::rotation3d() QVERIFY(transform2D(rotation).isIdentity()); } +void tst_QGraphicsTransform::rotation3dArbitraryAxis_data() +{ + QTest::addColumn("axis"); + QTest::addColumn("angle"); + + QVector3D axis1 = QVector3D(1.0f, 1.0f, 1.0f); + QVector3D axis2 = QVector3D(2.0f, -3.0f, 0.5f); + QVector3D axis3 = QVector3D(-2.0f, 0.0f, -0.5f); + QVector3D axis4 = QVector3D(0.0001f, 0.0001f, 0.0001f); + QVector3D axis5 = QVector3D(0.01f, 0.01f, 0.01f); + + for (int angle = 0; angle <= 360; angle++) { + QTest::newRow("test rotation on (1, 1, 1)") << axis1 << qreal(angle); + QTest::newRow("test rotation on (2, -3, .5)") << axis2 << qreal(angle); + QTest::newRow("test rotation on (-2, 0, -.5)") << axis3 << qreal(angle); + QTest::newRow("test rotation on (.0001, .0001, .0001)") << axis4 << qreal(angle); + QTest::newRow("test rotation on (.01, .01, .01)") << axis5 << qreal(angle); + } +} + +void tst_QGraphicsTransform::rotation3dArbitraryAxis() +{ + QFETCH(QVector3D, axis); + QFETCH(qreal, angle); + + QGraphicsRotation rotation; + rotation.setAxis(axis); + + QMatrix4x4 t; + rotation.applyTo(&t); + + QVERIFY(t.isIdentity()); + QVERIFY(transform2D(rotation).isIdentity()); + + rotation.setAngle(angle); + + // Compute the expected answer using QMatrix4x4 and a projection. + // These two steps are performed in one hit by QGraphicsRotation. + QMatrix4x4 exp; + exp.rotate(angle, axis); + QTransform expected = exp.toTransform(1024.0f); + + QVERIFY(fuzzyCompare(transform2D(rotation), expected)); + + // Check that "rotation" produces the 4x4 form of the 3x3 matrix. + // i.e. third row and column are 0 0 1 0. + t.setIdentity(); + rotation.applyTo(&t); + QMatrix4x4 r(expected); + QVERIFY(qFuzzyCompare(t, r)); +} + QTEST_MAIN(tst_QGraphicsTransform) #include "tst_qgraphicstransform.moc" -- cgit v0.12 From e7c6757f53f81442c138f4354db958a893d9e611 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 11:19:12 +1000 Subject: Fix ifdef around QMatrix4x4::rotate(QQuaternion) Reviewed-by: trustme --- src/gui/math3d/qmatrix4x4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index fa3826f..5d624d8 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -1209,7 +1209,7 @@ QMatrix4x4& QMatrix4x4::projectedRotate(qreal angle, qreal x, qreal y, qreal z) return *this; } -#ifndef QT_NO_VECTOR4D +#ifndef QT_NO_QUATERNION /*! Multiples this matrix by another that rotates coordinates according -- cgit v0.12 From 91462fa3ac02aa88e3aeeacfa9fc4d4dbb8fe2a1 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 11:47:54 +1000 Subject: Optimize concatenation of partial shaders Reviewed-by: Sarah Smith --- src/opengl/qglshaderprogram.cpp | 123 ++++++++++++++++++++++++++++++---------- src/opengl/qglshaderprogram.h | 2 + 2 files changed, 95 insertions(+), 30 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 34114e4..ecb2566 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -444,7 +444,8 @@ bool QGLShader::compile(const char *source) d->hasPartialSource = true; return d->compile(this); } else if (d->shaderGuard.id()) { - QVarLengthArray src; + QVarLengthArray src; + QVarLengthArray srclen; int headerLen = 0; while (source && source[headerLen] == '#') { // Skip #version and #extension directives at the start of @@ -459,21 +460,24 @@ bool QGLShader::compile(const char *source) if (source[headerLen] == '\n') ++headerLen; } - QByteArray header; if (headerLen > 0) { - header = QByteArray(source, headerLen); - src.append(header.constData()); + src.append(source); + srclen.append(GLint(headerLen)); } #ifdef QGL_DEFINE_QUALIFIERS src.append(qualifierDefines); + srclen.append(GLint(sizeof(qualifierDefines) - 1)); #endif #ifdef QGL_REDEFINE_HIGHP if (d->shaderType == FragmentShader || - d->shaderType == PartialFragmentShader) + d->shaderType == PartialFragmentShader) { src.append(redefineHighp); + srclen.append(GLint(sizeof(redefineHighp) - 1)); + } #endif src.append(source + headerLen); - glShaderSource(d->shaderGuard.id(), src.size(), src.data(), 0); + srclen.append(GLint(qstrlen(source + headerLen))); + glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data()); return d->compile(this); } else { return false; @@ -481,6 +485,60 @@ bool QGLShader::compile(const char *source) } /*! + \internal +*/ +bool QGLShader::compile + (const QList& shaders, QGLShader::ShaderType type) +{ + QVarLengthArray src; + QVarLengthArray srclen; + if (!d->shaderGuard.id()) + return false; + foreach (QGLShader *shader, shaders) { + if (shader->shaderType() != type) + continue; + const char *source = shader->d->partialSource.constData(); + int headerLen = 0; + if (src.isEmpty()) { + // First shader: handle the #version and #extension tags + // plus the precision qualifiers. + while (source && source[headerLen] == '#') { + // Skip #version and #extension directives at the start of + // the shader code. We need to insert the qualifierDefines + // and redefineHighp just after them. + if (qstrncmp(source + headerLen, "#version", 8) != 0 && + qstrncmp(source + headerLen, "#extension", 10) != 0) { + break; + } + while (source[headerLen] != '\0' && source[headerLen] != '\n') + ++headerLen; + if (source[headerLen] == '\n') + ++headerLen; + } + if (headerLen > 0) { + src.append(source); + srclen.append(GLint(headerLen)); + } +#ifdef QGL_DEFINE_QUALIFIERS + src.append(qualifierDefines); + srclen.append(GLint(sizeof(qualifierDefines) - 1)); +#endif +#ifdef QGL_REDEFINE_HIGHP + if (d->shaderType == FragmentShader || + d->shaderType == PartialFragmentShader) { + src.append(redefineHighp); + srclen.append(GLint(sizeof(redefineHighp) - 1)); + } +#endif + } + src.append(source + headerLen); + srclen.append(GLint(qstrlen(source + headerLen))); + } + glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data()); + return d->compile(this); +} + +/*! \overload Sets the \a source code for this shader and compiles it. @@ -713,6 +771,8 @@ public: QList anonShaders; QGLShader *vertexShader; QGLShader *fragmentShader; + + bool hasShader(QGLShader::ShaderType type) const; }; QGLShaderProgramPrivate::~QGLShaderProgramPrivate() @@ -723,6 +783,15 @@ QGLShaderProgramPrivate::~QGLShaderProgramPrivate() } } +bool QGLShaderProgramPrivate::hasShader(QGLShader::ShaderType type) const +{ + foreach (QGLShader *shader, shaders) { + if (shader->shaderType() == type) + return true; + } + return false; +} + #undef ctx #define ctx d->programGuard.context() @@ -1118,47 +1187,41 @@ bool QGLShaderProgram::link() return false; if (d->hasPartialShaders) { // Compile the partial vertex and fragment shaders. - QByteArray vertexSource; - QByteArray fragmentSource; - foreach (QGLShader *shader, d->shaders) { - if (shader->shaderType() == QGLShader::PartialVertexShader) - vertexSource += shader->sourceCode(); - else if (shader->shaderType() == QGLShader::PartialFragmentShader) - fragmentSource += shader->sourceCode(); - } - if (vertexSource.isEmpty()) { - if (d->vertexShader) { - glDetachShader(program, d->vertexShader->d->shaderGuard.id()); - delete d->vertexShader; - d->vertexShader = 0; - } - } else { + if (d->hasShader(QGLShader::PartialVertexShader)) { if (!d->vertexShader) { d->vertexShader = new QGLShader(QGLShader::VertexShader, this); } - if (!d->vertexShader->compile(vertexSource)) { + if (!d->vertexShader->compile + (d->shaders, QGLShader::PartialVertexShader)) { d->log = d->vertexShader->log(); return false; } glAttachShader(program, d->vertexShader->d->shaderGuard.id()); - } - if (fragmentSource.isEmpty()) { - if (d->fragmentShader) { - glDetachShader(program, d->fragmentShader->d->shaderGuard.id()); - delete d->fragmentShader; - d->fragmentShader = 0; - } } else { + if (d->vertexShader) { + glDetachShader(program, d->vertexShader->d->shaderGuard.id()); + delete d->vertexShader; + d->vertexShader = 0; + } + } + if (d->hasShader(QGLShader::PartialFragmentShader)) { if (!d->fragmentShader) { d->fragmentShader = new QGLShader(QGLShader::FragmentShader, this); } - if (!d->fragmentShader->compile(fragmentSource)) { + if (!d->fragmentShader->compile + (d->shaders, QGLShader::PartialFragmentShader)) { d->log = d->fragmentShader->log(); return false; } glAttachShader(program, d->fragmentShader->d->shaderGuard.id()); + } else { + if (d->fragmentShader) { + glDetachShader(program, d->fragmentShader->d->shaderGuard.id()); + delete d->fragmentShader; + d->fragmentShader = 0; + } } } glLinkProgram(program); diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index f2d70fa..2848b5f 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -106,6 +106,8 @@ private: friend class QGLShaderProgram; Q_DISABLE_COPY(QGLShader) + + bool compile(const QList& shaders, QGLShader::ShaderType type); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType) -- cgit v0.12 From a161143b81d8b4cfce06d2566dbbd129a2e1b0e1 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 12:14:58 +1000 Subject: Use QObjectPrivate within QGLShaderPrivate and QGLShaderProgramPrivate Reviewed-by: Sarah Smith --- src/opengl/qglshaderprogram.cpp | 175 ++++++++++++++++++++++++++++++---------- src/opengl/qglshaderprogram.h | 6 +- 2 files changed, 134 insertions(+), 47 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index ecb2566..7fcd6f7 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -42,6 +42,7 @@ #include "qglshaderprogram.h" #include "qglextensions_p.h" #include "qgl_p.h" +#include #include #include #include @@ -200,8 +201,9 @@ QT_BEGIN_NAMESPACE #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 #endif -class QGLShaderPrivate +class QGLShaderPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QGLShader) public: QGLShaderPrivate(const QGLContext *context, QGLShader::ShaderType type) : shaderGuard(context) @@ -211,6 +213,7 @@ public: , hasPartialSource(false) { } + ~QGLShaderPrivate(); QGLSharedResourceGuard shaderGuard; QGLShader::ShaderType shaderType; @@ -227,6 +230,14 @@ public: #define ctx shaderGuard.context() +QGLShaderPrivate::~QGLShaderPrivate() +{ + if (shaderGuard.id()) { + QGLShareContextScope scope(shaderGuard.context()); + glDeleteShader(shaderGuard.id()); + } +} + bool QGLShaderPrivate::create() { const QGLContext *context = shaderGuard.context(); @@ -306,9 +317,9 @@ void QGLShaderPrivate::deleteShader() \sa compile(), compileFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) { - d = new QGLShaderPrivate(QGLContext::currentContext(), type); + Q_D(QGLShader); d->create(); } @@ -323,13 +334,21 @@ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) */ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) { - d = new QGLShaderPrivate(QGLContext::currentContext(), type); + Q_D(QGLShader); if (d->create() && !compileFile(fileName)) d->deleteShader(); } +static inline const QGLContext *contextOrCurrent(const QGLContext *context) +{ + if (context) + return context; + else + return QGLContext::currentContext(); +} + /*! Constructs a new QGLShader object of the specified \a type and attaches it to \a parent. If shader programs are not supported, @@ -343,14 +362,12 @@ QGLShader::QGLShader \sa compile(), compileFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent) { - if (!context) - context = QGLContext::currentContext(); - d = new QGLShaderPrivate(context, type); + Q_D(QGLShader); #ifndef QT_NO_DEBUG if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) { - qWarning("QGLShader::QGLShader: \'context\' must be the currect context or sharing with it."); + qWarning("QGLShader::QGLShader: \'context\' must be the current context or sharing with it."); return; } #endif @@ -368,14 +385,12 @@ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObj */ QGLShader::QGLShader (const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent) { - if (!context) - context = QGLContext::currentContext(); - d = new QGLShaderPrivate(context, type); + Q_D(QGLShader); #ifndef QT_NO_DEBUG if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) { - qWarning("QGLShader::QGLShader: \'context\' must be currect context or sharing with it."); + qWarning("QGLShader::QGLShader: \'context\' must be current context or sharing with it."); return; } #endif @@ -390,11 +405,6 @@ QGLShader::QGLShader */ QGLShader::~QGLShader() { - if (d->shaderGuard.id()) { - QGLShareContextScope scope(d->shaderGuard.context()); - glDeleteShader(d->shaderGuard.id()); - } - delete d; } /*! @@ -402,6 +412,7 @@ QGLShader::~QGLShader() */ QGLShader::ShaderType QGLShader::shaderType() const { + Q_D(const QGLShader); return d->shaderType; } @@ -439,6 +450,7 @@ static const char redefineHighp[] = */ bool QGLShader::compile(const char *source) { + Q_D(QGLShader); if (d->isPartial) { d->partialSource = QByteArray(source); d->hasPartialSource = true; @@ -490,6 +502,7 @@ bool QGLShader::compile(const char *source) bool QGLShader::compile (const QList& shaders, QGLShader::ShaderType type) { + Q_D(QGLShader); QVarLengthArray src; QVarLengthArray srclen; if (!d->shaderGuard.id()) @@ -497,7 +510,7 @@ bool QGLShader::compile foreach (QGLShader *shader, shaders) { if (shader->shaderType() != type) continue; - const char *source = shader->d->partialSource.constData(); + const char *source = shader->d_func()->partialSource.constData(); int headerLen = 0; if (src.isEmpty()) { // First shader: handle the #version and #extension tags @@ -613,6 +626,7 @@ bool QGLShader::compileFile(const QString& fileName) */ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) { + Q_D(QGLShader); #if !defined(QT_OPENGL_ES_2) if (!glShaderBinary) return false; @@ -646,21 +660,22 @@ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length) bool QGLShader::setShaderBinary (QGLShader& otherShader, GLenum format, const void *binary, int length) { + Q_D(QGLShader); #if !defined(QT_OPENGL_ES_2) if (!glShaderBinary) return false; #endif if (d->isPartial || !d->shaderGuard.id()) return false; - if (otherShader.d->isPartial || !otherShader.d->shaderGuard.id()) + if (otherShader.d_func()->isPartial || !otherShader.d_func()->shaderGuard.id()) return false; glGetError(); // Clear error state. GLuint shaders[2]; shaders[0] = d->shaderGuard.id(); - shaders[1] = otherShader.d->shaderGuard.id(); + shaders[1] = otherShader.d_func()->shaderGuard.id(); glShaderBinary(2, shaders, format, binary, length); d->compiled = (glGetError() == GL_NO_ERROR); - otherShader.d->compiled = d->compiled; + otherShader.d_func()->compiled = d->compiled; return d->compiled; } @@ -692,6 +707,7 @@ QList QGLShader::shaderBinaryFormats() */ QByteArray QGLShader::sourceCode() const { + Q_D(const QGLShader); if (d->isPartial) return d->partialSource; GLuint shader = d->shaderGuard.id(); @@ -716,6 +732,7 @@ QByteArray QGLShader::sourceCode() const */ bool QGLShader::isCompiled() const { + Q_D(const QGLShader); return d->compiled; } @@ -726,6 +743,7 @@ bool QGLShader::isCompiled() const */ QString QGLShader::log() const { + Q_D(const QGLShader); return d->log; } @@ -740,14 +758,16 @@ QString QGLShader::log() const */ GLuint QGLShader::shaderId() const { + Q_D(const QGLShader); return d->shaderGuard.id(); } #undef ctx #define ctx programGuard.context() -class QGLShaderProgramPrivate +class QGLShaderProgramPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QGLShaderProgram) public: QGLShaderProgramPrivate(const QGLContext *context) : programGuard(context) @@ -804,9 +824,8 @@ bool QGLShaderProgramPrivate::hasShader(QGLShader::ShaderType type) const \sa addShader() */ QGLShaderProgram::QGLShaderProgram(QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderProgramPrivate(QGLContext::currentContext()), parent) { - d = new QGLShaderProgramPrivate(QGLContext::currentContext()); } /*! @@ -818,9 +837,8 @@ QGLShaderProgram::QGLShaderProgram(QObject *parent) \sa addShader() */ QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent) - : QObject(parent) + : QObject(*new QGLShaderProgramPrivate(context), parent) { - d = new QGLShaderProgramPrivate(context); } /*! @@ -828,11 +846,11 @@ QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent) */ QGLShaderProgram::~QGLShaderProgram() { - delete d; } bool QGLShaderProgram::init() { + Q_D(QGLShaderProgram); if (d->programGuard.id() || d->inited) return true; d->inited = true; @@ -870,22 +888,23 @@ bool QGLShaderProgram::init() */ bool QGLShaderProgram::addShader(QGLShader *shader) { + Q_D(QGLShaderProgram); if (!init()) return false; if (d->shaders.contains(shader)) return true; // Already added to this shader program. if (d->programGuard.id() && shader) { - if (!QGLContext::areSharing(shader->d->shaderGuard.context(), + if (!QGLContext::areSharing(shader->d_func()->shaderGuard.context(), d->programGuard.context())) { qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context."); return false; } - if (!shader->d->compiled) + if (!shader->d_func()->compiled) return false; - if (!shader->d->isPartial) { - if (!shader->d->shaderGuard.id()) + if (!shader->d_func()->isPartial) { + if (!shader->d_func()->shaderGuard.id()) return false; - glAttachShader(d->programGuard.id(), shader->d->shaderGuard.id()); + glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); } else { d->hasPartialShaders = true; } @@ -912,6 +931,7 @@ bool QGLShaderProgram::addShader(QGLShader *shader) */ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source) { + Q_D(QGLShaderProgram); if (!init()) return false; QGLShader *shader = new QGLShader(type, this); @@ -977,6 +997,7 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QString& sour bool QGLShaderProgram::addShaderFromFile (QGLShader::ShaderType type, const QString& fileName) { + Q_D(QGLShaderProgram); if (!init()) return false; QGLShader *shader = new QGLShader(type, this); @@ -996,9 +1017,10 @@ bool QGLShaderProgram::addShaderFromFile */ void QGLShaderProgram::removeShader(QGLShader *shader) { - if (d->programGuard.id() && shader && shader->d->shaderGuard.id()) { + Q_D(QGLShaderProgram); + if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id()) { QGLShareContextScope scope(d->programGuard.context()); - glDetachShader(d->programGuard.id(), shader->d->shaderGuard.id()); + glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); } d->linked = false; // Program needs to be relinked. if (shader) { @@ -1016,6 +1038,7 @@ void QGLShaderProgram::removeShader(QGLShader *shader) */ QList QGLShaderProgram::shaders() const { + Q_D(const QGLShaderProgram); return d->shaders; } @@ -1029,10 +1052,11 @@ QList QGLShaderProgram::shaders() const */ void QGLShaderProgram::removeAllShaders() { + Q_D(QGLShaderProgram); d->removingShaders = true; foreach (QGLShader *shader, d->shaders) { - if (d->programGuard.id() && shader && shader->d->shaderGuard.id()) - glDetachShader(d->programGuard.id(), shader->d->shaderGuard.id()); + if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id()) + glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); } foreach (QGLShader *shader, d->anonShaders) { // Delete shader objects that were created anonymously. @@ -1078,6 +1102,7 @@ void QGLShaderProgram::removeAllShaders() QByteArray QGLShaderProgram::programBinary(int *format) const { #if defined(QT_OPENGL_ES_2) + Q_D(const QGLShaderProgram); if (!isLinked()) return QByteArray(); @@ -1113,6 +1138,7 @@ bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary) { #if defined(QT_OPENGL_ES_2) // Load the binary and check that it was linked correctly. + Q_D(const QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1182,6 +1208,7 @@ QList QGLShaderProgram::programBinaryFormats() */ bool QGLShaderProgram::link() { + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1197,10 +1224,10 @@ bool QGLShaderProgram::link() d->log = d->vertexShader->log(); return false; } - glAttachShader(program, d->vertexShader->d->shaderGuard.id()); + glAttachShader(program, d->vertexShader->d_func()->shaderGuard.id()); } else { if (d->vertexShader) { - glDetachShader(program, d->vertexShader->d->shaderGuard.id()); + glDetachShader(program, d->vertexShader->d_func()->shaderGuard.id()); delete d->vertexShader; d->vertexShader = 0; } @@ -1215,10 +1242,10 @@ bool QGLShaderProgram::link() d->log = d->fragmentShader->log(); return false; } - glAttachShader(program, d->fragmentShader->d->shaderGuard.id()); + glAttachShader(program, d->fragmentShader->d_func()->shaderGuard.id()); } else { if (d->fragmentShader) { - glDetachShader(program, d->fragmentShader->d->shaderGuard.id()); + glDetachShader(program, d->fragmentShader->d_func()->shaderGuard.id()); delete d->fragmentShader; d->fragmentShader = 0; } @@ -1253,6 +1280,7 @@ bool QGLShaderProgram::link() */ bool QGLShaderProgram::isLinked() const { + Q_D(const QGLShaderProgram); return d->linked; } @@ -1264,6 +1292,7 @@ bool QGLShaderProgram::isLinked() const */ QString QGLShaderProgram::log() const { + Q_D(const QGLShaderProgram); return d->log; } @@ -1277,6 +1306,7 @@ QString QGLShaderProgram::log() const */ bool QGLShaderProgram::enable() { + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; @@ -1315,6 +1345,7 @@ void QGLShaderProgram::disable() */ GLuint QGLShaderProgram::programId() const { + Q_D(const QGLShaderProgram); return d->programGuard.id(); } @@ -1328,6 +1359,7 @@ GLuint QGLShaderProgram::programId() const */ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) { + Q_D(QGLShaderProgram); if (!d->linked) { glBindAttribLocation(d->programGuard.id(), location, name); } else { @@ -1375,6 +1407,7 @@ void QGLShaderProgram::bindAttributeLocation(const QString& name, int location) */ int QGLShaderProgram::attributeLocation(const char *name) const { + Q_D(const QGLShaderProgram); if (d->linked) { return glGetAttribLocation(d->programGuard.id(), name); } else { @@ -1419,6 +1452,7 @@ int QGLShaderProgram::attributeLocation(const QString& name) const */ void QGLShaderProgram::setAttributeValue(int location, GLfloat value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib1fv(location, &value); } @@ -1443,6 +1477,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat value) */ void QGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[2] = {x, y}; glVertexAttrib2fv(location, values); @@ -1471,6 +1506,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat x, GLfloat y) void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[3] = {x, y, z}; glVertexAttrib3fv(location, values); @@ -1500,6 +1536,7 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glVertexAttrib4fv(location, values); @@ -1527,6 +1564,7 @@ void QGLShaderProgram::setAttributeValue */ void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib2fv(location, reinterpret_cast(&value)); } @@ -1550,6 +1588,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector2D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QVector3D& value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib3fv(location, reinterpret_cast(&value)); } @@ -1573,6 +1612,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector3D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QVector4D& value) { + Q_D(QGLShaderProgram); if (location != -1) glVertexAttrib4fv(location, reinterpret_cast(&value)); } @@ -1596,6 +1636,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector4D& valu */ void QGLShaderProgram::setAttributeValue(int location, const QColor& value) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {value.redF(), value.greenF(), value.blueF(), value.alphaF()}; glVertexAttrib4fv(location, values); @@ -1626,6 +1667,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QColor& value) void QGLShaderProgram::setAttributeValue (int location, const GLfloat *values, int columns, int rows) { + Q_D(QGLShaderProgram); if (rows < 1 || rows > 4) { qWarning() << "QGLShaderProgram::setAttributeValue: rows" << rows << "not supported"; return; @@ -1675,6 +1717,7 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeArray (int location, const GLfloat *values, int size, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, stride, values); @@ -1693,6 +1736,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector2D *values, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, stride, values); @@ -1711,6 +1755,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector3D *values, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, stride, values); @@ -1729,6 +1774,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::setAttributeArray (int location, const QVector4D *values, int stride) { + Q_D(QGLShaderProgram); if (location != -1) { glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, stride, values); @@ -1809,6 +1855,7 @@ void QGLShaderProgram::setAttributeArray */ void QGLShaderProgram::disableAttributeArray(int location) { + Q_D(QGLShaderProgram); if (location != -1) glDisableVertexAttribArray(location); } @@ -1835,6 +1882,7 @@ void QGLShaderProgram::disableAttributeArray(const char *name) */ int QGLShaderProgram::uniformLocation(const char *name) const { + Q_D(const QGLShaderProgram); if (d->linked) { return glGetUniformLocation(d->programGuard.id(), name); } else { @@ -1879,6 +1927,7 @@ int QGLShaderProgram::uniformLocation(const QString& name) const */ void QGLShaderProgram::setUniformValue(int location, GLfloat value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1fv(location, 1, &value); } @@ -1903,6 +1952,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat value) */ void QGLShaderProgram::setUniformValue(int location, GLint value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1i(location, value); } @@ -1928,6 +1978,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLint value) */ void QGLShaderProgram::setUniformValue(int location, GLuint value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1i(location, value); } @@ -1953,6 +2004,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLuint value) */ void QGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[2] = {x, y}; glUniform2fv(location, 1, values); @@ -1981,6 +2033,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat x, GLfloat y) void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[3] = {x, y, z}; glUniform3fv(location, 1, values); @@ -2010,6 +2063,7 @@ void QGLShaderProgram::setUniformValue void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glUniform4fv(location, 1, values); @@ -2037,6 +2091,7 @@ void QGLShaderProgram::setUniformValue */ void QGLShaderProgram::setUniformValue(int location, const QVector2D& value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform2fv(location, 1, reinterpret_cast(&value)); } @@ -2061,6 +2116,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector2D& value) */ void QGLShaderProgram::setUniformValue(int location, const QVector3D& value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform3fv(location, 1, reinterpret_cast(&value)); } @@ -2085,6 +2141,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector3D& value) */ void QGLShaderProgram::setUniformValue(int location, const QVector4D& value) { + Q_D(QGLShaderProgram); if (location != -1) glUniform4fv(location, 1, reinterpret_cast(&value)); } @@ -2110,6 +2167,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector4D& value) */ void QGLShaderProgram::setUniformValue(int location, const QColor& color) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {color.redF(), color.greenF(), color.blueF(), color.alphaF()}; glUniform4fv(location, 1, values); @@ -2137,6 +2195,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QColor& color) */ void QGLShaderProgram::setUniformValue(int location, const QPoint& point) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2164,6 +2223,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point) */ void QGLShaderProgram::setUniformValue(int location, const QPointF& point) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2191,6 +2251,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point) */ void QGLShaderProgram::setUniformValue(int location, const QSize& size) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {size.width(), size.width()}; glUniform2fv(location, 1, values); @@ -2218,6 +2279,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSize& size) */ void QGLShaderProgram::setUniformValue(int location, const QSizeF& size) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat values[4] = {size.width(), size.height()}; glUniform2fv(location, 1, values); @@ -2297,6 +2359,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size) */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value) { + Q_D(QGLShaderProgram); setUniformMatrix(glUniformMatrix2fv, location, value, 2, 2); } @@ -2321,6 +2384,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix2x3fv, glUniform3fv, location, value, 2, 3); } @@ -2346,6 +2410,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix2x4fv, glUniform4fv, location, value, 2, 4); } @@ -2371,6 +2436,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix3x2fv, glUniform2fv, location, value, 3, 2); } @@ -2396,6 +2462,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value) { + Q_D(QGLShaderProgram); setUniformMatrix(glUniformMatrix3fv, location, value, 3, 3); } @@ -2420,6 +2487,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix3x4fv, glUniform4fv, location, value, 3, 4); } @@ -2445,6 +2513,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix4x2fv, glUniform2fv, location, value, 4, 2); } @@ -2470,6 +2539,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value) { + Q_D(QGLShaderProgram); setUniformGenericMatrix (glUniformMatrix4x3fv, glUniform3fv, location, value, 4, 3); } @@ -2495,6 +2565,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value */ void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value) { + Q_D(QGLShaderProgram); setUniformMatrix(glUniformMatrix4fv, location, value, 4, 4); } @@ -2522,6 +2593,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value */ void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4]) { + Q_D(QGLShaderProgram); if (location != -1) glUniformMatrix4fv(location, 1, GL_FALSE, value[0]); } @@ -2549,6 +2621,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][ */ void QGLShaderProgram::setUniformValue(int location, const QTransform& value) { + Q_D(QGLShaderProgram); if (location != -1) { GLfloat mat[3][3] = { {value.m11(), value.m12(), value.m13()}, @@ -2582,6 +2655,7 @@ void QGLShaderProgram::setUniformValue */ void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1iv(location, count, values); } @@ -2609,6 +2683,7 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform1iv(location, count, reinterpret_cast(values)); } @@ -2637,6 +2712,7 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int size) { + Q_D(QGLShaderProgram); if (location != -1) { if (size == 1) glUniform1fv(location, count, values); @@ -2674,6 +2750,7 @@ void QGLShaderProgram::setUniformValueArray */ void QGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform2fv(location, count, reinterpret_cast(values)); } @@ -2699,6 +2776,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform3fv(location, count, reinterpret_cast(values)); } @@ -2724,6 +2802,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count) { + Q_D(QGLShaderProgram); if (location != -1) glUniform4fv(location, count, reinterpret_cast(values)); } @@ -2810,6 +2889,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *v */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count) { + Q_D(QGLShaderProgram); setUniformMatrixArray (glUniformMatrix2fv, location, values, count, QMatrix2x2, 2, 2); } @@ -2835,6 +2915,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix2x3fv, glUniform3fv, location, values, count, QMatrix2x3, 2, 3); @@ -2861,6 +2942,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix2x4fv, glUniform4fv, location, values, count, QMatrix2x4, 2, 4); @@ -2887,6 +2969,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix3x2fv, glUniform2fv, location, values, count, QMatrix3x2, 3, 2); @@ -2913,6 +2996,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count) { + Q_D(QGLShaderProgram); setUniformMatrixArray (glUniformMatrix3fv, location, values, count, QMatrix3x3, 3, 3); } @@ -2938,6 +3022,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix3x4fv, glUniform4fv, location, values, count, QMatrix3x4, 3, 4); @@ -2964,6 +3049,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix4x2fv, glUniform2fv, location, values, count, QMatrix4x2, 4, 2); @@ -2990,6 +3076,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count) { + Q_D(QGLShaderProgram); setUniformGenericMatrixArray (glUniformMatrix4x3fv, glUniform3fv, location, values, count, QMatrix4x3, 4, 3); @@ -3016,6 +3103,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 * */ void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count) { + Q_D(QGLShaderProgram); setUniformMatrixArray (glUniformMatrix4fv, location, values, count, QMatrix4x4, 4, 4); } @@ -3061,6 +3149,7 @@ bool QGLShaderProgram::hasShaderPrograms(const QGLContext *context) */ void QGLShaderProgram::shaderDestroyed() { + Q_D(QGLShaderProgram); QGLShader *shader = qobject_cast(sender()); if (shader && !d->removingShaders) removeShader(shader); diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index 2848b5f..d8b9a0c 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -101,11 +101,10 @@ public: GLuint shaderId() const; private: - QGLShaderPrivate *d; - friend class QGLShaderProgram; Q_DISABLE_COPY(QGLShader) + Q_DECLARE_PRIVATE(QGLShader) bool compile(const QList& shaders, QGLShader::ShaderType type); }; @@ -288,9 +287,8 @@ private Q_SLOTS: void shaderDestroyed(); private: - QGLShaderProgramPrivate *d; - Q_DISABLE_COPY(QGLShaderProgram) + Q_DECLARE_PRIVATE(QGLShaderProgram) bool init(); }; -- cgit v0.12 From f97cbb44be9e6195ee5a15a687a963ea5bb2f547 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 12:41:19 +1000 Subject: Fix OpenGL/ES 2.0 bug in previous QGLShaderProgram check-in --- src/opengl/qglshaderprogram.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 7fcd6f7..b20c6e9 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -1138,7 +1138,7 @@ bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary) { #if defined(QT_OPENGL_ES_2) // Load the binary and check that it was linked correctly. - Q_D(const QGLShaderProgram); + Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); if (!program) return false; -- cgit v0.12 From ded1dbb7e898364dd1cd2b1b129673569805a786 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 13:02:06 +1000 Subject: Suppress warnings under OpenGL/ES 2.0 in QGLShaderProgram --- src/opengl/qglshaderprogram.cpp | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index b20c6e9..d028522 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -1453,6 +1453,7 @@ int QGLShaderProgram::attributeLocation(const QString& name) const void QGLShaderProgram::setAttributeValue(int location, GLfloat value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib1fv(location, &value); } @@ -1478,6 +1479,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, GLfloat value) void QGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[2] = {x, y}; glVertexAttrib2fv(location, values); @@ -1507,6 +1509,7 @@ void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[3] = {x, y, z}; glVertexAttrib3fv(location, values); @@ -1537,6 +1540,7 @@ void QGLShaderProgram::setAttributeValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glVertexAttrib4fv(location, values); @@ -1565,6 +1569,7 @@ void QGLShaderProgram::setAttributeValue void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib2fv(location, reinterpret_cast(&value)); } @@ -1589,6 +1594,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector2D& valu void QGLShaderProgram::setAttributeValue(int location, const QVector3D& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib3fv(location, reinterpret_cast(&value)); } @@ -1613,6 +1619,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector3D& valu void QGLShaderProgram::setAttributeValue(int location, const QVector4D& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glVertexAttrib4fv(location, reinterpret_cast(&value)); } @@ -1637,6 +1644,7 @@ void QGLShaderProgram::setAttributeValue(const char *name, const QVector4D& valu void QGLShaderProgram::setAttributeValue(int location, const QColor& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {value.redF(), value.greenF(), value.blueF(), value.alphaF()}; glVertexAttrib4fv(location, values); @@ -1668,6 +1676,7 @@ void QGLShaderProgram::setAttributeValue (int location, const GLfloat *values, int columns, int rows) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (rows < 1 || rows > 4) { qWarning() << "QGLShaderProgram::setAttributeValue: rows" << rows << "not supported"; return; @@ -1718,6 +1727,7 @@ void QGLShaderProgram::setAttributeArray (int location, const GLfloat *values, int size, int stride) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, stride, values); @@ -1737,6 +1747,7 @@ void QGLShaderProgram::setAttributeArray (int location, const QVector2D *values, int stride) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, stride, values); @@ -1756,6 +1767,7 @@ void QGLShaderProgram::setAttributeArray (int location, const QVector3D *values, int stride) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, stride, values); @@ -1775,6 +1787,7 @@ void QGLShaderProgram::setAttributeArray (int location, const QVector4D *values, int stride) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, stride, values); @@ -1856,6 +1869,7 @@ void QGLShaderProgram::setAttributeArray void QGLShaderProgram::disableAttributeArray(int location) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glDisableVertexAttribArray(location); } @@ -1883,6 +1897,7 @@ void QGLShaderProgram::disableAttributeArray(const char *name) int QGLShaderProgram::uniformLocation(const char *name) const { Q_D(const QGLShaderProgram); + Q_UNUSED(d); if (d->linked) { return glGetUniformLocation(d->programGuard.id(), name); } else { @@ -1928,6 +1943,7 @@ int QGLShaderProgram::uniformLocation(const QString& name) const void QGLShaderProgram::setUniformValue(int location, GLfloat value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1fv(location, 1, &value); } @@ -1953,6 +1969,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLfloat value) void QGLShaderProgram::setUniformValue(int location, GLint value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1i(location, value); } @@ -1979,6 +1996,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLint value) void QGLShaderProgram::setUniformValue(int location, GLuint value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1i(location, value); } @@ -2005,6 +2023,7 @@ void QGLShaderProgram::setUniformValue(const char *name, GLuint value) void QGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[2] = {x, y}; glUniform2fv(location, 1, values); @@ -2034,6 +2053,7 @@ void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[3] = {x, y, z}; glUniform3fv(location, 1, values); @@ -2064,6 +2084,7 @@ void QGLShaderProgram::setUniformValue (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {x, y, z, w}; glUniform4fv(location, 1, values); @@ -2092,6 +2113,7 @@ void QGLShaderProgram::setUniformValue void QGLShaderProgram::setUniformValue(int location, const QVector2D& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform2fv(location, 1, reinterpret_cast(&value)); } @@ -2117,6 +2139,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector2D& value) void QGLShaderProgram::setUniformValue(int location, const QVector3D& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform3fv(location, 1, reinterpret_cast(&value)); } @@ -2142,6 +2165,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector3D& value) void QGLShaderProgram::setUniformValue(int location, const QVector4D& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform4fv(location, 1, reinterpret_cast(&value)); } @@ -2168,6 +2192,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QVector4D& value) void QGLShaderProgram::setUniformValue(int location, const QColor& color) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {color.redF(), color.greenF(), color.blueF(), color.alphaF()}; glUniform4fv(location, 1, values); @@ -2196,6 +2221,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QColor& color) void QGLShaderProgram::setUniformValue(int location, const QPoint& point) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2224,6 +2250,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point) void QGLShaderProgram::setUniformValue(int location, const QPointF& point) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {point.x(), point.y()}; glUniform2fv(location, 1, values); @@ -2252,6 +2279,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point) void QGLShaderProgram::setUniformValue(int location, const QSize& size) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {size.width(), size.width()}; glUniform2fv(location, 1, values); @@ -2280,6 +2308,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSize& size) void QGLShaderProgram::setUniformValue(int location, const QSizeF& size) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat values[4] = {size.width(), size.height()}; glUniform2fv(location, 1, values); @@ -2360,6 +2389,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size) void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrix(glUniformMatrix2fv, location, value, 2, 2); } @@ -2385,6 +2415,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix2x3fv, glUniform3fv, location, value, 2, 3); } @@ -2411,6 +2442,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix2x4fv, glUniform4fv, location, value, 2, 4); } @@ -2437,6 +2469,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix3x2fv, glUniform2fv, location, value, 3, 2); } @@ -2463,6 +2496,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrix(glUniformMatrix3fv, location, value, 3, 3); } @@ -2488,6 +2522,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix3x4fv, glUniform4fv, location, value, 3, 4); } @@ -2514,6 +2549,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix4x2fv, glUniform2fv, location, value, 4, 2); } @@ -2540,6 +2576,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrix (glUniformMatrix4x3fv, glUniform3fv, location, value, 4, 3); } @@ -2566,6 +2603,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrix(glUniformMatrix4fv, location, value, 4, 4); } @@ -2594,6 +2632,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4]) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniformMatrix4fv(location, 1, GL_FALSE, value[0]); } @@ -2622,6 +2661,7 @@ void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][ void QGLShaderProgram::setUniformValue(int location, const QTransform& value) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { GLfloat mat[3][3] = { {value.m11(), value.m12(), value.m13()}, @@ -2656,6 +2696,7 @@ void QGLShaderProgram::setUniformValue void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1iv(location, count, values); } @@ -2684,6 +2725,7 @@ void QGLShaderProgram::setUniformValueArray void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform1iv(location, count, reinterpret_cast(values)); } @@ -2713,6 +2755,7 @@ void QGLShaderProgram::setUniformValueArray void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int size) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) { if (size == 1) glUniform1fv(location, count, values); @@ -2751,6 +2794,7 @@ void QGLShaderProgram::setUniformValueArray void QGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform2fv(location, count, reinterpret_cast(values)); } @@ -2777,6 +2821,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *v void QGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform3fv(location, count, reinterpret_cast(values)); } @@ -2803,6 +2848,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *v void QGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); if (location != -1) glUniform4fv(location, count, reinterpret_cast(values)); } @@ -2890,6 +2936,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *v void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrixArray (glUniformMatrix2fv, location, values, count, QMatrix2x2, 2, 2); } @@ -2916,6 +2963,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix2x3fv, glUniform3fv, location, values, count, QMatrix2x3, 2, 3); @@ -2943,6 +2991,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix2x4fv, glUniform4fv, location, values, count, QMatrix2x4, 2, 4); @@ -2970,6 +3019,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix3x2fv, glUniform2fv, location, values, count, QMatrix3x2, 3, 2); @@ -2997,6 +3047,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrixArray (glUniformMatrix3fv, location, values, count, QMatrix3x3, 3, 3); } @@ -3023,6 +3074,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix3x4fv, glUniform4fv, location, values, count, QMatrix3x4, 3, 4); @@ -3050,6 +3102,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix4x2fv, glUniform2fv, location, values, count, QMatrix4x2, 4, 2); @@ -3077,6 +3130,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformGenericMatrixArray (glUniformMatrix4x3fv, glUniform3fv, location, values, count, QMatrix4x3, 4, 3); @@ -3104,6 +3158,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 * void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count) { Q_D(QGLShaderProgram); + Q_UNUSED(d); setUniformMatrixArray (glUniformMatrix4fv, location, values, count, QMatrix4x4, 4, 4); } -- cgit v0.12 From 35c8033ff51ab6d0567e786b790b8cc49852803b Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 26 Oct 2009 13:09:05 +1000 Subject: Suppress warnings in QtOpenGL code --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 1 + src/opengl/qwindowsurface_gl.cpp | 2 +- src/opengl/qwindowsurface_x11gl.cpp | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index bcc6bdb..a0810bc 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1263,6 +1263,7 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) QGLContext *ctx = d->ctx; + Q_UNUSED(ctx); if (opaque) { d->prepareForDraw(opaque); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 4547416..42e1c1e 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -364,7 +364,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (ctxpriv->eglSurface == EGL_NO_SURFACE) { qWarning() << "hijackWindow() could not create EGL surface"; } - qDebug("QGLWindowSurface - using EGLConfig %d", ctxpriv->eglContext->config()); + qDebug("QGLWindowSurface - using EGLConfig %d", reinterpret_cast(ctxpriv->eglContext->config())); #endif widgetPrivate->extraData()->glContext = ctx; diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp index 8ef239d..db81be2 100644 --- a/src/opengl/qwindowsurface_x11gl.cpp +++ b/src/opengl/qwindowsurface_x11gl.cpp @@ -124,6 +124,9 @@ void QX11GLWindowSurface::setGeometry(const QRect &rect) bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy) { + Q_UNUSED(area); + Q_UNUSED(dx); + Q_UNUSED(dy); return false; } -- cgit v0.12