summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-09-04 10:42:15 +0200
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-09-07 12:39:07 +0000
commit4564e476d663c8b6170a5fc68d83306d8835b27b (patch)
tree395e2140dba7ad6107dd3e24ebbdec141ad1399c
parent9d71cd48bfc248419035dad811fcfbd317d9b54d (diff)
downloadqtgraphicaleffects-4564e476d663c8b6170a5fc68d83306d8835b27b.tar.gz
restore previous context in QGfxShaderBuilder
QGfxShaderBuilder can be called while we're in the process of rendering a window. We must restore the previous OpenGL context instead of making a null context current. Change-Id: I6d1158bbcee781a7850d5fc7bea9e7070d62c0f6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
-rw-r--r--src/effects/private/qgfxshaderbuilder.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/effects/private/qgfxshaderbuilder.cpp b/src/effects/private/qgfxshaderbuilder.cpp
index 0d04681..87b1a45 100644
--- a/src/effects/private/qgfxshaderbuilder.cpp
+++ b/src/effects/private/qgfxshaderbuilder.cpp
@@ -61,6 +61,9 @@ QGfxShaderBuilder::QGfxShaderBuilder()
// GL context's format on to the offscreen format.
surface.setFormat(context.format());
surface.create();
+
+ QOpenGLContext *oldContext = QOpenGLContext::currentContext();
+ QSurface *oldSurface = oldContext ? oldContext->surface() : 0;
if (context.makeCurrent(&surface)) {
QOpenGLFunctions *gl = context.functions();
if (context.isOpenGLES()) {
@@ -74,7 +77,10 @@ QGfxShaderBuilder::QGfxShaderBuilder()
gl->glGetIntegerv(GL_MAX_VARYING_FLOATS, &floats);
m_maxBlurSamples = floats / 2.0;
}
- context.doneCurrent();
+ if (oldContext && oldSurface)
+ oldContext->makeCurrent(oldSurface);
+ else
+ context.doneCurrent();
} else {
qDebug() << "failed to acquire GL context to resolve capabilities, using defaults..";
m_maxBlurSamples = 8; // minimum number of varyings in the ES 2.0 spec.