diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-03-23 16:18:19 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-03-30 20:48:07 +0000 |
commit | 2266f519225eebca724dd658d185f96bc9ad086c (patch) | |
tree | 3824fcff1fd510ae5489647ec8eee2ce22777451 /tests | |
parent | 2c1d597b653f16dc80a87d637c94213120f32d90 (diff) |
Fix incorrect FBO bindings with QOpenGLWidget
QOpenGLContext::defaultFramebufferObject() knows nothing about QOpenGLWidget
and QQuickWidget. The problem is that this function (and others that rely on it)
is expected to give the widget's backing FBO in paintGL() and friends.
To overcome this, we have to provide a way for such widgets that indicate what is
the expected "default fbo".
Task-number: QTBUG-43269
Change-Id: I43f439f8609382b9f7004707ab0ef9f091952b4f
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 0c0c50ac64..e9f9c67856 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -56,6 +56,7 @@ private slots: void reparentToNotYetCreated(); void asViewport(); void requestUpdate(); + void fboRedirect(); }; void tst_QOpenGLWidget::create() @@ -329,6 +330,31 @@ void tst_QOpenGLWidget::requestUpdate() QTRY_VERIFY(w.m_count > 0); } +class FboCheckWidget : public QOpenGLWidget +{ +public: + void paintGL() Q_DECL_OVERRIDE { + GLuint reportedDefaultFbo = QOpenGLContext::currentContext()->defaultFramebufferObject(); + GLuint expectedDefaultFbo = defaultFramebufferObject(); + QCOMPARE(reportedDefaultFbo, expectedDefaultFbo); + } +}; + +void tst_QOpenGLWidget::fboRedirect() +{ + FboCheckWidget w; + w.resize(640, 480); + w.show(); + QTest::qWaitForWindowExposed(&w); + + // Unlike in paintGL(), the default fbo reported by the context is not affected by the widget, + // so we get the real default fbo: either 0 or (on iOS) the fbo associated with the window. + w.makeCurrent(); + GLuint reportedDefaultFbo = QOpenGLContext::currentContext()->defaultFramebufferObject(); + GLuint widgetFbo = w.defaultFramebufferObject(); + QVERIFY(reportedDefaultFbo != widgetFbo); +} + QTEST_MAIN(tst_QOpenGLWidget) #include "tst_qopenglwidget.moc" |