diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-09-10 09:48:52 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-09-10 11:04:47 (GMT) |
commit | 774d17db636dcef03a69cfa9cfb5f5a1127d10e9 (patch) | |
tree | 77ff4db1a3c925763d511e47451899c333b6efc3 /tests/auto/qgl | |
parent | a0d1af5e48de5c3e8b6754ee15f973c479c789c5 (diff) | |
download | Qt-774d17db636dcef03a69cfa9cfb5f5a1127d10e9.zip Qt-774d17db636dcef03a69cfa9cfb5f5a1127d10e9.tar.gz Qt-774d17db636dcef03a69cfa9cfb5f5a1127d10e9.tar.bz2 |
Add an autotest for QGLWidget::renderPixmap()
Diffstat (limited to 'tests/auto/qgl')
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 662d7b7..ebbfbae 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -77,6 +77,7 @@ private slots: void glFBOUseInGLWidget(); void glPBufferRendering(); void glWidgetReparent(); + void glWidgetRenderPixmap(); void stackedFBOs(); void colormap(); void fboFormat(); @@ -1157,6 +1158,35 @@ void tst_QGL::glWidgetReparent() delete widget; } +class RenderPixmapWidget : public QGLWidget +{ +protected: + void initializeGL() { + // Set some gl state: + glClearColor(1.0, 0.0, 0.0, 1.0); + } + + void paintGL() { + glClear(GL_COLOR_BUFFER_BIT); + } +}; + +void tst_QGL::glWidgetRenderPixmap() +{ + RenderPixmapWidget *w = new RenderPixmapWidget; + + QPixmap pm = w->renderPixmap(100, 100, false); + + delete w; + + QImage fb = pm.toImage().convertToFormat(QImage::Format_RGB32); + QImage reference(fb.size(), QImage::Format_RGB32); + reference.fill(0xffff0000); + + QCOMPARE(fb, reference); +} + + // When using multiple FBOs at the same time, unbinding one FBO should re-bind the // previous. I.e. It should be possible to have a stack of FBOs where pop'ing there // top re-binds the one underneeth. |