summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-08-07 16:45:05 +0200
committerLaszlo Agocs <laszlo.agocs@digia.com>2014-08-08 07:29:29 +0200
commit22e439141384f49028770d2410fafb18ef8cad1f (patch)
treed30ada7a9da27083c464948654ad1d87b21d1f65 /tests
parent41a7072195eef0f7daa94d0ce75a3f68e721d1cb (diff)
Add default format to QSurfaceFormat
Add defaultFormat() and setDefaultFormat() statics to QSurfaceFormat. These define the default values for the requestedFormat members of QOpenGLContext, QWindow and QOpenGLWidget (and implicitly QOpenGLWindow, QQuickWindow, etc.) This replaces QQuickWindow::setDefaultFormat() which can now be removed. The main inspiration here is not the convenience (avoiding setFormat() calls for all windows/widgets), but robustness: by setting the format once at the start of the application, all windows and contexts, including the internal share context used by QOpenGLWidget and QQuickWidget, will use the same format, eliminating the possibility of failing due to trying to share between incompatible contexts. Furthermore, since such a functionality is anyway mandatory for QQuickWindow (due to the possibility of creating windows from QML code), extending it to QSurfaceFormat and QOpenGLContext/QWindow is the next logical step. Change-Id: Ie94486adc489d17fecfcebb7050fecedffd2688b Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 6d83defdeb..a5100a57bf 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -102,6 +102,7 @@ private slots:
void textureblitterPartOriginTopLeftSourceRectTransform();
void textureblitterFullTargetRectTransform();
void textureblitterPartTargetRectTransform();
+ void defaultSurfaceFormat();
#ifdef USE_GLX
void glxContextWrap();
@@ -1110,6 +1111,23 @@ void tst_QOpenGL::textureblitterPartTargetRectTransform()
QCOMPARE(targetBottomRight, expectedBottomRight);
}
+void tst_QOpenGL::defaultSurfaceFormat()
+{
+ QSurfaceFormat fmt;
+ QVERIFY(QSurfaceFormat::defaultFormat() == fmt);
+
+ fmt.setDepthBufferSize(16);
+ QSurfaceFormat::setDefaultFormat(fmt);
+ QVERIFY(QSurfaceFormat::defaultFormat() == fmt);
+ QCOMPARE(QSurfaceFormat::defaultFormat().depthBufferSize(), 16);
+
+ QScopedPointer<QWindow> window(new QWindow);
+ QVERIFY(window->requestedFormat() == fmt);
+
+ QScopedPointer<QOpenGLContext> context(new QOpenGLContext);
+ QVERIFY(context->format() == fmt);
+}
+
#ifdef USE_GLX
void tst_QOpenGL::glxContextWrap()
{