diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2012-01-25 18:27:50 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-27 11:01:14 +0100 |
commit | 7f9b624e12731afc21f332c081b9c9a9e2a8c55e (patch) | |
tree | 8e9e3a8b2745801bbc1c44f6ef648d72057e8ec9 /src/plugins/platforms/xlib | |
parent | 2d39471897f0a3a769406ec9c2b39558ebd45af3 (diff) |
Fall back on glXChooseVisual() if glXChooseFBConfig() doesn't work.
Some older drivers don't fully support glXChooseFBConfig(). As a bonus,
fix some memory leaks here and there.
Task-number: QTBUG-21880
Change-Id: Ie306dee27f616927a6aa55fd71601569b828afcc
Reviewed-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/plugins/platforms/xlib')
-rw-r--r-- | src/plugins/platforms/xlib/qglxintegration.cpp | 16 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibwindow.cpp | 33 |
2 files changed, 30 insertions, 19 deletions
diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp index 875e166672..80ea371eab 100644 --- a/src/plugins/platforms/xlib/qglxintegration.cpp +++ b/src/plugins/platforms/xlib/qglxintegration.cpp @@ -70,9 +70,19 @@ QGLXContext::QGLXContext(QXlibScreen *screen, const QSurfaceFormat &format, QPla if (share) shareGlxContext = static_cast<const QGLXContext*>(share)->glxContext(); - GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format); - m_context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE); - m_windowFormat = qglx_surfaceFormatFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context); + Display *xDisplay = screen->display()->nativeDisplay(); + + GLXFBConfig config = qglx_findConfig(xDisplay,screen->xScreenNumber(),format); + if (config) { + m_context = glXCreateNewContext(xDisplay,config,GLX_RGBA_TYPE,shareGlxContext,TRUE); + m_windowFormat = qglx_surfaceFormatFromGLXFBConfig(xDisplay,config,m_context); + } else { + XVisualInfo *visualInfo = qglx_findVisualInfo(xDisplay, screen->xScreenNumber(), format); + if (!visualInfo) + qFatal("Could not initialize GLX"); + m_context = glXCreateContext(xDisplay, visualInfo, shareGlxContext, true); + XFree(visualInfo); + } #ifdef MYX11_DEBUG qDebug() << "QGLXGLContext::create context" << m_context; diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index d5724d6050..6c9081c9ca 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -87,6 +87,8 @@ QXlibWindow::QXlibWindow(QWindow *window) #if !defined(QT_OPENGL_ES_2) XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber(), window->format()); + if (!visualInfo) + qFatal("Could not initialize GLX"); #else QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat()); @@ -101,23 +103,22 @@ QXlibWindow::QXlibWindow(QWindow *window) XVisualInfo *visualInfo; int matchingCount = 0; visualInfo = XGetVisualInfo(mScreen->display()->nativeDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount); + if (!visualInfo) + qFatal("Could not initialize EGL"); #endif //!defined(QT_OPENGL_ES_2) - if (visualInfo) { - mDepth = visualInfo->depth; - mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; - mVisual = visualInfo->visual; - Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), visualInfo->visual, AllocNone); - - XSetWindowAttributes a; - a.background_pixel = WhitePixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); - a.border_pixel = BlackPixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); - a.colormap = cmap; - x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h, - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWBackPixel|CWBorderPixel|CWColormap, &a); - } else { - qFatal("no window!"); - } + mDepth = visualInfo->depth; + mFormat = (mDepth == 32) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; + mVisual = visualInfo->visual; + Colormap cmap = XCreateColormap(mScreen->display()->nativeDisplay(), mScreen->rootWindow(), visualInfo->visual, AllocNone); + + XSetWindowAttributes a; + a.background_pixel = WhitePixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); + a.border_pixel = BlackPixel(mScreen->display()->nativeDisplay(), mScreen->xScreenNumber()); + a.colormap = cmap; + x_window = XCreateWindow(mScreen->display()->nativeDisplay(), mScreen->rootWindow(),x, y, w, h, + 0, visualInfo->depth, InputOutput, visualInfo->visual, + CWBackPixel|CWBorderPixel|CWColormap, &a); + XFree(visualInfo); } else #endif //!defined(QT_NO_OPENGL) { |