From 2266f519225eebca724dd658d185f96bc9ad086c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 23 Mar 2015 16:18:19 +0100 Subject: 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 Reviewed-by: Gunnar Sletta --- .../widgets/qopenglwidget/tst_qopenglwidget.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') 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" -- cgit v1.2.3