summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-08-28 15:31:21 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-08-28 15:33:13 (GMT)
commit78fdde630cb16086ef24d8e79adcf0f91a729ddb (patch)
treee313c4210d6c8603a6062f38c57f7ff288975836 /tests
parentd6d49aa56750359012cdf722df27b0a1c3e5b2aa (diff)
downloadQt-78fdde630cb16086ef24d8e79adcf0f91a729ddb.zip
Qt-78fdde630cb16086ef24d8e79adcf0f91a729ddb.tar.gz
Qt-78fdde630cb16086ef24d8e79adcf0f91a729ddb.tar.bz2
Add an autotest to check QPainter rendering to a QGLPixelBuffer works
Reviewed-by: Trustme
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgl/tst_qgl.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index ae31572..59779b0 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -45,6 +45,7 @@
#include <qcoreapplication.h>
#include <qdebug.h>
#include <qgl.h>
+#include <qglpixelbuffer.h>
#include <qglcolormap.h>
#include <qpaintengine.h>
@@ -70,6 +71,7 @@ private slots:
void partialGLWidgetUpdates_data();
void partialGLWidgetUpdates();
void glWidgetRendering();
+ void glPBufferRendering();
void glWidgetReparent();
void colormap();
};
@@ -630,6 +632,37 @@ void tst_QGL::partialGLWidgetUpdates()
}
+// This tests that rendering to a QGLPBuffer using QPainter works.
+void tst_QGL::glPBufferRendering()
+{
+ if (!QGLPixelBuffer::hasOpenGLPbuffers())
+ QSKIP("QGLPixelBuffer not supported on this platform", SkipSingle);
+
+ QGLPixelBuffer* pbuf = new QGLPixelBuffer(128, 128);
+
+ QPainter p;
+ bool begun = p.begin(pbuf);
+ QVERIFY(begun);
+
+ QPaintEngine::Type engineType = p.paintEngine()->type();
+ QVERIFY(engineType == QPaintEngine::OpenGL || engineType == QPaintEngine::OpenGL2);
+
+ p.fillRect(0, 0, 128, 128, Qt::red);
+ p.fillRect(32, 32, 64, 64, Qt::blue);
+ p.end();
+
+ QImage fb = pbuf->toImage();
+ delete pbuf;
+
+ QImage reference(128, 128, fb.format());
+ p.begin(&reference);
+ p.fillRect(0, 0, 128, 128, Qt::red);
+ p.fillRect(32, 32, 64, 64, Qt::blue);
+ p.end();
+
+ QCOMPARE(fb, reference);
+}
+
class GLWidget : public QGLWidget
{
public: