summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-09-01 17:19:35 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-09-01 17:19:35 (GMT)
commit70a24d46f0feca317cca731a302367e8c847c32e (patch)
tree2c94d63e05ced38e5f9279263dd2fe2780ce5b97 /tests/auto
parentfb920977b1afd105ae87109d9ee930f5a2fe0b90 (diff)
parent57b3d45dff62e0f23508601caf2560edd3dee33b (diff)
downloadQt-70a24d46f0feca317cca731a302367e8c847c32e.zip
Qt-70a24d46f0feca317cca731a302367e8c847c32e.tar.gz
Qt-70a24d46f0feca317cca731a302367e8c847c32e.tar.bz2
Merge branch '4.6'
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgl/tst_qgl.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 1629542..f979174 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -73,6 +73,7 @@ private slots:
void partialGLWidgetUpdates();
void glWidgetRendering();
void glFBORendering();
+ void glFBOUseInGLWidget();
void glPBufferRendering();
void glWidgetReparent();
void colormap();
@@ -769,6 +770,60 @@ void tst_QGL::glFBORendering()
QCOMPARE(fb.pixel(192, 64), QColor(Qt::green).rgb());
}
+class FBOUseInGLWidget : public QGLWidget
+{
+public:
+ bool widgetPainterBeginOk;
+ bool fboPainterBeginOk;
+ QImage fboImage;
+protected:
+ void paintEvent(QPaintEvent*)
+ {
+ QPainter widgetPainter;
+ widgetPainterBeginOk = widgetPainter.begin(this);
+ QGLFramebufferObjectFormat fboFormat(0, QGLFramebufferObject::CombinedDepthStencil);
+ QGLFramebufferObject *fbo = new QGLFramebufferObject(128, 128, fboFormat);
+
+ QPainter fboPainter;
+ fboPainterBeginOk = fboPainter.begin(fbo);
+ fboPainter.fillRect(0, 0, 128, 128, Qt::red);
+ fboPainter.end();
+ fboImage = fbo->toImage();
+
+ widgetPainter.fillRect(rect(), Qt::blue);
+
+ delete fbo;
+ }
+
+};
+
+void tst_QGL::glFBOUseInGLWidget()
+{
+ if (!QGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle);
+
+ FBOUseInGLWidget w;
+ w.resize(128, 128);
+ w.show();
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&w);
+#endif
+ QTest::qWait(200);
+
+ QVERIFY(w.widgetPainterBeginOk);
+ QVERIFY(w.fboPainterBeginOk);
+
+ QImage widgetFB = w.grabFrameBuffer(false);
+ QImage widgetReference(widgetFB.size(), widgetFB.format());
+ widgetReference.fill(0xff0000ff);
+ QCOMPARE(widgetFB, widgetReference);
+
+ QImage fboReference(w.fboImage.size(), w.fboImage.format());
+ fboReference.fill(0xffff0000);
+ QCOMPARE(w.fboImage, fboReference);
+}
+
void tst_QGL::glWidgetReparent()
{
// Try it as a top-level first: