From f2b26af2b4db25aeb74279a40365b76f0406a018 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 20 Feb 2013 14:00:52 +0100 Subject: [PATCH] Enforce OpenGL context creation under XCB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't support other context types, so fail in those cases. Also, return OpenGL as the rendereable type of our surface. Change-Id: Ic7b5ed0ec5eaf5c0f88f50f5bceb697ea414c696 Reviewed-by: Samuel Rødal Reviewed-by: Gunnar Sletta --- .../glxconvenience/qglxconvenience.cpp | 2 ++ src/plugins/platforms/xcb/qglxintegration.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp index e885ecc105..9ce74f55fe 100644 --- a/src/platformsupport/glxconvenience/qglxconvenience.cpp +++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp @@ -224,6 +224,8 @@ XVisualInfo *qglx_findVisualInfo(Display *display, int screen, QSurfaceFormat *f QSurfaceFormat qglx_surfaceFormatFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) { QSurfaceFormat format; + format.setRenderableType(QSurfaceFormat::OpenGL); + int redSize = 0; int greenSize = 0; int blueSize = 0; diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 854f7bcd17..db942fc3ad 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -270,14 +270,19 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat : QPlatformOpenGLContext() , m_screen(screen) , m_context(0) + , m_shareContext(0) , m_format(format) , m_isPBufferCurrent(false) { - m_shareContext = 0; + if (m_format.renderableType() == QSurfaceFormat::DefaultRenderableType) + m_format.setRenderableType(QSurfaceFormat::OpenGL); + if (m_format.renderableType() != QSurfaceFormat::OpenGL) + return; + if (share) m_shareContext = static_cast(share)->glxContext(); - GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); + GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),m_format); XVisualInfo *visualInfo = 0; Window window = 0; // Temporary window used to query OpenGL context @@ -297,7 +302,7 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat // context format that that which was requested and is supported by the driver const int maxSupportedVersion = (defaultContextInfo->format.majorVersion() << 8) + defaultContextInfo->format.minorVersion(); - const int requestedVersion = qMin((format.majorVersion() << 8) + format.minorVersion(), + const int requestedVersion = qMin((m_format.majorVersion() << 8) + m_format.minorVersion(), maxSupportedVersion); const int majorVersion = requestedVersion >> 8; const int minorVersion = requestedVersion & 0xFF;