From 774d17db636dcef03a69cfa9cfb5f5a1127d10e9 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 10 Sep 2009 11:48:52 +0200 Subject: Add an autotest for QGLWidget::renderPixmap() --- tests/auto/qgl/tst_qgl.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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. -- cgit v0.12