summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2010-05-26 14:39:02 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-04-05 07:10:36 (GMT)
commit2f59eaeee1fbe33d07b0e7d0747afd8658df95ac (patch)
tree900f0a504d26e901fb7134ed52179ec8617ccbe4 /src/opengl/gl2paintengineex
parent07df7ee20a0f3027516ad03465a2fb7b7e38e864 (diff)
downloadQt-2f59eaeee1fbe33d07b0e7d0747afd8658df95ac.zip
Qt-2f59eaeee1fbe33d07b0e7d0747afd8658df95ac.tar.gz
Qt-2f59eaeee1fbe33d07b0e7d0747afd8658df95ac.tar.bz2
Made extension resolving work with Core profile.
The Core profile was introduced in OpenGL 3.2 and if chosen removes all deprecated functionality from the OpenGL API. In the Core profile glGetString(GL_EXTENSIONS) is unsupported, so instead we need to use glGetStringi(GL_EXTENSIONS, index) together with glGetIntegerv(GL_NUM_EXTENSIONS). Also optimized the QGLExtensionMatcher to not have to recompute the split positions all the time. Preliminary support to prevent non-core-functions to be called in the GL 2 engine has also been added. Reviewed-by: Kim
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 4d1d5dc..18c684f 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -540,27 +540,32 @@ void QGL2PaintEngineEx::beginNativePainting()
glDisableVertexAttribArray(i);
#ifndef QT_OPENGL_ES_2
- // be nice to people who mix OpenGL 1.x code with QPainter commands
- // by setting modelview and projection matrices to mirror the GL 1
- // paint engine
- const QTransform& mtx = state()->matrix;
-
- float mv_matrix[4][4] =
+ const QGLFormat &fmt = d->device->format();
+ if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1)
+ || fmt.profile() == QGLFormat::CompatibilityProfile)
{
- { float(mtx.m11()), float(mtx.m12()), 0, float(mtx.m13()) },
- { float(mtx.m21()), float(mtx.m22()), 0, float(mtx.m23()) },
- { 0, 0, 1, 0 },
- { float(mtx.dx()), float(mtx.dy()), 0, float(mtx.m33()) }
- };
+ // be nice to people who mix OpenGL 1.x code with QPainter commands
+ // by setting modelview and projection matrices to mirror the GL 1
+ // paint engine
+ const QTransform& mtx = state()->matrix;
- const QSize sz = d->device->size();
+ float mv_matrix[4][4] =
+ {
+ { float(mtx.m11()), float(mtx.m12()), 0, float(mtx.m13()) },
+ { float(mtx.m21()), float(mtx.m22()), 0, float(mtx.m23()) },
+ { 0, 0, 1, 0 },
+ { float(mtx.dx()), float(mtx.dy()), 0, float(mtx.m33()) }
+ };
+
+ const QSize sz = d->device->size();
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);
- glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf(&mv_matrix[0][0]);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixf(&mv_matrix[0][0]);
+ }
#else
Q_UNUSED(ctx);
#endif
@@ -591,7 +596,9 @@ void QGL2PaintEngineExPrivate::resetGLState()
ctx->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false);
ctx->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false);
#ifndef QT_OPENGL_ES_2
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // color may have been changed by glVertexAttrib()
+ // gl_Color, corresponding to vertex attribute 3, may have been changed
+ float color[] = { 1.0f, 1.0f, 1.0f, 1.0f };
+ glVertexAttrib4fv(3, color);
#endif
}