diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-06 13:10:20 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-08-06 13:10:20 (GMT) |
commit | 47bed030ffedded5914d8309bf2e1cccc1fd78d0 (patch) | |
tree | 6e497e442549b6bc405995a4a2b45c6ce6b600f0 /src | |
parent | 1d8ce23abdb0bd980292e4a9c8d87c019585150a (diff) | |
download | Qt-47bed030ffedded5914d8309bf2e1cccc1fd78d0.zip Qt-47bed030ffedded5914d8309bf2e1cccc1fd78d0.tar.gz Qt-47bed030ffedded5914d8309bf2e1cccc1fd78d0.tar.bz2 |
Added reduced config to glxconfig
should help if there are not many glxconfigs available. Also made
QGLTemporaryContext use a QWidget again instead of a QGLWidget; This
allows us to ask for a smaller window size before making the context.
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 14 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qglxintegration.cpp | 68 | ||||
-rw-r--r-- | src/plugins/platforms/testlite/qglxintegration.h | 1 |
3 files changed, 60 insertions, 23 deletions
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index d87e668..c328819 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -244,7 +244,7 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) class QGLTemporaryContextPrivate { public: - QGLWidget *widget; + QWidget *widget; QGLContext *context; }; @@ -254,13 +254,19 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) d->context = const_cast<QGLContext *>(QGLContext::currentContext()); if (d->context) d->context->doneCurrent(); - d->widget = new QGLWidget; - d->widget->makeCurrent(); + d->widget = new QWidget; + d->widget->setGeometry(0,0,3,3); + QPlatformWindowFormat format = d->widget->platformWindowFormat(); + format.setWindowApi(QPlatformWindowFormat::OpenGL); + d->widget->winId(); + + + d->widget->platformWindow()->glContext()->makeCurrent(); } QGLTemporaryContext::~QGLTemporaryContext() { - d->widget->doneCurrent(); + d->widget->platformWindow()->glContext()->doneCurrent(); if (d->context) d->context->makeCurrent(); delete d->widget; diff --git a/src/plugins/platforms/testlite/qglxintegration.cpp b/src/plugins/platforms/testlite/qglxintegration.cpp index 050643c..ba161c1 100644 --- a/src/plugins/platforms/testlite/qglxintegration.cpp +++ b/src/plugins/platforms/testlite/qglxintegration.cpp @@ -113,28 +113,33 @@ QVector<int> QGLXGLContext::buildSpec(const QPlatformWindowFormat &format) GLXFBConfig QGLXGLContext::findConfig(const MyDisplay *xd, const QPlatformWindowFormat &format) { - QVector<int> spec = buildSpec(format); - int confcount = 0; - GLXFBConfig *configs; + bool reduced = true; GLXFBConfig chosenConfig = 0; - configs = glXChooseFBConfig(xd->display,xd->screen,spec.constData(),&confcount); - if (confcount) - { - for (int i = 0; i < confcount; i++) { - chosenConfig = configs[i]; - - // Make sure we try to get an ARGB visual if the format asked for an alpha: - if (format.alpha()) { - int alphaSize; - glXGetFBConfigAttrib(xd->display,configs[i],GLX_ALPHA_SIZE,&alphaSize); - if (alphaSize > 0) - break; - } else { - break; // Just choose the first in the list if there's no alpha requested + QPlatformWindowFormat reducedFormat = format; + while (!chosenConfig && reduced) { + QVector<int> spec = buildSpec(reducedFormat); + int confcount = 0; + GLXFBConfig *configs; + configs = glXChooseFBConfig(xd->display,xd->screen,spec.constData(),&confcount); + if (confcount) + { + for (int i = 0; i < confcount; i++) { + chosenConfig = configs[i]; + + // Make sure we try to get an ARGB visual if the format asked for an alpha: + if (format.alpha()) { + int alphaSize; + glXGetFBConfigAttrib(xd->display,configs[i],GLX_ALPHA_SIZE,&alphaSize); + if (alphaSize > 0) + break; + } else { + break; // Just choose the first in the list if there's no alpha requested + } } - } - XFree(configs); + XFree(configs); + } + reducedFormat = reducePlatformWindowFormat(format,&reduced); } if (!chosenConfig) @@ -206,6 +211,31 @@ QPlatformWindowFormat QGLXGLContext::platformWindowFromGLXFBConfig(Display *disp return format; } +QPlatformWindowFormat QGLXGLContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) +{ + QPlatformWindowFormat retFormat = format; + *reduced = true; + + if (retFormat.sampleBuffers()) { + retFormat.setSampleBuffers(false); + } else if (retFormat.stereo()) { + retFormat.setStereo(false); + } else if (retFormat.accum()) { + retFormat.setAccum(false); + }else if (retFormat.stencil()) { + retFormat.setStencil(false); + }else if (retFormat.alpha()) { + retFormat.setAlpha(false); + }else if (retFormat.depth()) { + retFormat.setDepth(false); + }else if (retFormat.doubleBuffer()) { + retFormat.setDoubleBuffer(false); + }else{ + *reduced = false; + } + return retFormat; +} + QGLXGLContext::QGLXGLContext(Window window, MyDisplay *xd, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_xd(xd) diff --git a/src/plugins/platforms/testlite/qglxintegration.h b/src/plugins/platforms/testlite/qglxintegration.h index 562967a..479be4b 100644 --- a/src/plugins/platforms/testlite/qglxintegration.h +++ b/src/plugins/platforms/testlite/qglxintegration.h @@ -75,6 +75,7 @@ private: static GLXFBConfig findConfig(const MyDisplay *xd,const QPlatformWindowFormat &format); static QVector<int> buildSpec(const QPlatformWindowFormat &format); static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); + static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); MyDisplay *m_xd; |