summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qglxintegration.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-09-01 10:43:42 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-09-01 14:10:12 +0200
commitda2b3c4479e1d23ea6ead555cadc96a56967887a (patch)
tree20ebe47749dcf233f70f3db00d22125c41116e5c /src/plugins/platforms/xcb/qglxintegration.cpp
parentd06fb5609c02d639e44e932988f428c13aab71c3 (diff)
Prevent current context from becoming inconsistent upon create()
Platform plugins have a tendency to make the newly created native context current with a temporary surface. This is usually needed to query some information related to the new context. Afterwards most of them just reset to having nothing current. This has two issues: It unexpectedly changes the current context/surface. A call into QOpenGLContext::create() does not imply that the current context will get changed. This is the minor issue and we could probably live with it (at least if it had been documented). However, the real issue is that QOpenGLContext::currentContext() will become inconsistent: it will still report whatever was current before the create() even though on the EGL/WGL/GLX level that's not the case anymore. To prevent all this confusion the platform plugins can easily be changed to restore whatever context/surface was current before they altered it. Change-Id: I6a5b4597c86571327524ddb13e0d02538593cc7b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/plugins/platforms/xcb/qglxintegration.cpp')
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index d6fe5f3477..3b13df863e 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -323,11 +323,11 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share)
// Query the OpenGL version and profile
if (m_context && window) {
+ GLXContext prevContext = glXGetCurrentContext();
+ GLXDrawable prevDrawable = glXGetCurrentDrawable();
glXMakeCurrent(DISPLAY_FROM_XCB(screen), window, m_context);
updateFormatFromContext(m_format);
-
- // Make our context non-current
- glXMakeCurrent(DISPLAY_FROM_XCB(screen), 0, 0);
+ glXMakeCurrent(DISPLAY_FROM_XCB(screen), prevDrawable, prevContext);
}
// Destroy our temporary window
@@ -419,6 +419,8 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const
}
// Update OpenGL version and buffer sizes in our format.
+ GLXContext prevContext = glXGetCurrentContext();
+ GLXDrawable prevDrawable = glXGetCurrentDrawable();
if (!glXMakeCurrent(dpy, window, context)) {
qWarning("QGLXContext: Failed to make provided context current");
return;
@@ -431,7 +433,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const
qglx_surfaceFormatFromVisualInfo(&m_format, dpy, vinfo);
else
qglx_surfaceFormatFromGLXFBConfig(&m_format, dpy, config);
- glXMakeCurrent(dpy, 0, 0);
+ glXMakeCurrent(dpy, prevDrawable, prevContext);
XDestroyWindow(dpy, window);
if (vinfo)