summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp37
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h1
-rw-r--r--src/opengl/qgl_p.h2
3 files changed, 39 insertions, 1 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index e7b6ee4..40f3a8d 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -449,6 +449,43 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
+void QGL2PaintEngineEx::sync()
+{
+ Q_D(QGL2PaintEngineEx);
+ ensureActive();
+ d->transferMode(BrushDrawingMode);
+
+ QGLContext *ctx = d->ctx;
+ glUseProgram(0);
+
+#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] =
+ {
+ { mtx.m11(), mtx.m12(), 0, mtx.m13() },
+ { mtx.m21(), mtx.m22(), 0, mtx.m23() },
+ { 0, 0, 1, 0 },
+ { mtx.dx(), mtx.dy(), 0, mtx.m33() }
+ };
+
+ const QSize sz = d->drawable.size();
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, sz.width(), sz.height(), 0, -999999, 999999);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixf(&mv_matrix[0][0]);
+#endif
+
+ glDisable(GL_BLEND);
+ glActiveTexture(GL_TEXTURE0);
+}
+
void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode)
{
if (newMode == mode)
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index dececa3..7213474 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -126,6 +126,7 @@ public:
return static_cast<const QOpenGL2PaintEngineState *>(QPaintEngineEx::state());
}
void updateClipRegion(const QRegion &clipRegion, Qt::ClipOperation op);
+ virtual void sync();
private:
Q_DISABLE_COPY(QGL2PaintEngineEx)
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index b1a63b5..b3523d4 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -440,7 +440,7 @@ inline bool qt_gl_preferGL2Engine()
return true;
#else
return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0)
- && !qgetenv("QT_GL_USE_OPENGL2ENGINE").isEmpty();
+ && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty();
#endif
}