diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2010-07-26 06:18:18 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2010-07-27 07:57:59 (GMT) |
commit | 925fc21fcfdb48093032921e76c9274512699a9c (patch) | |
tree | a2c4087f6d7657cb4b0b2957dfa10e07245f8c65 /src/opengl/qgl_qpa.cpp | |
parent | 11a16e38df8022b41aae0d41a67e8b5542801d1c (diff) | |
download | Qt-925fc21fcfdb48093032921e76c9274512699a9c.zip Qt-925fc21fcfdb48093032921e76c9274512699a9c.tar.gz Qt-925fc21fcfdb48093032921e76c9274512699a9c.tar.bz2 |
Added QGLFormat to QPlatformWindowFormat conversion
Diffstat (limited to 'src/opengl/qgl_qpa.cpp')
-rw-r--r-- | src/opengl/qgl_qpa.cpp | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 917842b..8fa210b 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -52,6 +52,67 @@ QT_BEGIN_NAMESPACE +static QGLFormat qt_platformwindowformat_to_glformat(const QPlatformWindowFormat &format) +{ + QGLFormat retFormat; + retFormat.setAccum(format.accum()); + if (format.accumBufferSize() >= 0) + retFormat.setAccumBufferSize(format.accumBufferSize()); + retFormat.setAlpha(format.alpha()); + if (format.alphaBufferSize() >= 0) + retFormat.setAlphaBufferSize(format.alphaBufferSize()); + if (format.blueBufferSize() >= 0) + retFormat.setBlueBufferSize(format.blueBufferSize()); + retFormat.setDepth(format.depth()); + if (format.depthBufferSize() >= 0) + retFormat.setDepthBufferSize(format.depthBufferSize()); + retFormat.setDirectRendering(format.directRendering()); + retFormat.setDoubleBuffer(format.doubleBuffer()); + if (format.greenBufferSize() >= 0) + retFormat.setGreenBufferSize(format.greenBufferSize()); + if (format.redBufferSize() >= 0) + retFormat.setRedBufferSize(format.redBufferSize()); + retFormat.setRgba(format.rgba()); + retFormat.setSampleBuffers(format.sampleBuffers()); + retFormat.setSamples(format.sampleBuffers()); + retFormat.setStencil(format.stencil()); + if (format.stencilBufferSize() >= 0) + retFormat.setStencilBufferSize(format.stencilBufferSize()); + retFormat.setStereo(format.stereo()); + retFormat.setSwapInterval(format.swapInterval()); + return retFormat; +} + +static QPlatformWindowFormat qt_glformat_to_platformwindowformat(const QGLFormat &format) +{ + QPlatformWindowFormat retFormat; + retFormat.setAccum(format.accum()); + if (format.accumBufferSize() >= 0) + retFormat.setAccumBufferSize(format.accumBufferSize()); + retFormat.setAlpha(format.alpha()); + if (format.alphaBufferSize() >= 0) + retFormat.setAlphaBufferSize(format.alphaBufferSize()); + if (format.blueBufferSize() >= 0) + retFormat.setBlueBufferSize(format.blueBufferSize()); + retFormat.setDepth(format.depth()); + if (format.depthBufferSize() >= 0) + retFormat.setDepthBufferSize(format.depthBufferSize()); + retFormat.setDirectRendering(format.directRendering()); + retFormat.setDoubleBuffer(format.doubleBuffer()); + if (format.greenBufferSize() >= 0) + retFormat.setGreenBufferSize(format.greenBufferSize()); + if (format.redBufferSize() >= 0) + retFormat.setRedBufferSize(format.redBufferSize()); + retFormat.setRgba(format.rgba()); + retFormat.setSampleBuffers(format.sampleBuffers()); + retFormat.setSamples(format.sampleBuffers()); + retFormat.setStencil(format.stencil()); + if (format.stencilBufferSize() >= 0) + retFormat.setStencilBufferSize(format.stencilBufferSize()); + retFormat.setStereo(format.stereo()); + retFormat.setSwapInterval(format.swapInterval()); + return retFormat; +} bool QGLFormat::hasOpenGL() { @@ -61,14 +122,15 @@ bool QGLFormat::hasOpenGL() bool QGLContext::chooseContext(const QGLContext* shareContext) { Q_D(QGLContext); - if (!d->paintDevice && d->paintDevice->devType() != QInternal::Widget) { + if (!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) { d->valid = false; }else { QWidget *widget = static_cast<QWidget *>(d->paintDevice); if (!widget->platformWindow()){ - QPlatformWindowFormat format = widget->platformWindowFormat(); - format.setWindowApi(QPlatformWindowFormat::OpenGL); - widget->setPlatformWindowFormat(format); + QGLFormat glformat = format(); + QPlatformWindowFormat winFormat = qt_glformat_to_platformwindowformat(glformat); + winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + widget->setPlatformWindowFormat(winFormat); widget->winId();//make window } d->platformContext = widget->platformWindow()->glContext(); |