Warn if the OpenGL context lacks depth/stencil when requested.
authorGunnar Sletta <gunnar.sletta@digia.com>
Tue, 5 Feb 2013 12:45:24 +0000 (13:45 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 5 Feb 2013 15:36:45 +0000 (16:36 +0100)
I thought this was a serious bug in the renderer, but it turned out to
be qmlscene just overriding the surface format without requesting the
needed depth and stencil buffers. An easy mistake to make, hence
introduce the warning.

Task-number: QTBUG-29037
Change-Id: I59d09d1b2a139e3add851777ff2eeb6c4efb47ec
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
src/quick/scenegraph/qsgcontext.cpp

index e7e10ec..705b12c 100644 (file)
@@ -249,6 +249,14 @@ void QSGContext::initialize(QOpenGLContext *context)
 {
     Q_D(QSGContext);
 
+    // Sanity check the surface format, in case it was overridden by the application
+    QSurfaceFormat requested = defaultSurfaceFormat();
+    QSurfaceFormat actual = context->format();
+    if (requested.depthBufferSize() > 0 && actual.depthBufferSize() <= 0)
+        qWarning("QSGContext::initialize: depth buffer support missing, expect rendering errors");
+    if (requested.stencilBufferSize() > 0 && actual.stencilBufferSize() <= 0)
+        qWarning("QSGContext::initialize: stencil buffer support missing, expect rendering errors");
+
     Q_ASSERT(!d->gl);
     d->gl = context;