aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickwidgets
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-02-21 13:04:57 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-21 14:21:53 +0100
commit3eb56ecb7776fa106d1fb6e43355e2c1bf5c1d0c (patch)
treef6da76057aca1e95b79e3e31a5080492a5e84b35 /src/quickwidgets
parent08c4a88a77563e50860c34164414fe014271ccc2 (diff)
Fix missing depth and stencil buffer in QQuickWidget
Change-Id: I34f2015d63d3052b401a82bb4ac7340af94dca8c Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/quickwidgets')
-rw-r--r--src/quickwidgets/qquickwidget.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index e8dec60bc4..840877d72e 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -499,8 +499,18 @@ void QQuickWidgetPrivate::createContext()
if (context)
return;
- context = new QOpenGLContext();
- context->setFormat(q->window()->windowHandle()->requestedFormat());
+ context = new QOpenGLContext;
+
+ QSurfaceFormat format = q->window()->windowHandle()->requestedFormat();
+ QSGRenderContext *renderContext = QQuickWindowPrivate::get(offscreenWindow)->context;
+ // Depth, stencil, etc. must be set like a QQuickWindow would do.
+ QSurfaceFormat sgFormat = renderContext->sceneGraphContext()->defaultSurfaceFormat();
+ format.setDepthBufferSize(qMax(format.depthBufferSize(), sgFormat.depthBufferSize()));
+ format.setStencilBufferSize(qMax(format.stencilBufferSize(), sgFormat.stencilBufferSize()));
+ format.setAlphaBufferSize(qMax(format.alphaBufferSize(), sgFormat.alphaBufferSize()));
+ format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
+ context->setFormat(format);
+
if (QSGContext::sharedOpenGLContext())
context->setShareContext(QSGContext::sharedOpenGLContext()); // ??? is this correct
if (!context->create()) {