summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgl
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-09-07 00:53:32 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-09-07 00:53:32 (GMT)
commit5175f0f5079dc160f515f6069d0e287a2b08f0f8 (patch)
tree5aefddf444c1d68342196a1496ad9734b5f08ad7 /tests/auto/qgl
parent6d908473ec1a8c72f4bbb9d772e801024c3a62a0 (diff)
downloadQt-5175f0f5079dc160f515f6069d0e287a2b08f0f8.zip
Qt-5175f0f5079dc160f515f6069d0e287a2b08f0f8.tar.gz
Qt-5175f0f5079dc160f515f6069d0e287a2b08f0f8.tar.bz2
Unit tests for QGLFramebufferObjectFormat
Reviewed-by: trustme
Diffstat (limited to 'tests/auto/qgl')
-rw-r--r--tests/auto/qgl/tst_qgl.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 0fefbf3..d0f45b5 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -79,6 +79,7 @@ private slots:
void glWidgetReparent();
void stackedFBOs();
void colormap();
+ void fboFormat();
};
tst_QGL::tst_QGL()
@@ -1321,5 +1322,60 @@ void tst_QGL::colormap()
QCOMPARE(cmap4.size(), 256);
}
+#ifndef QT_OPENGL_ES
+#define DEFAULT_FORMAT GL_RGBA8
+#else
+#define DEFAULT_FORMAT GL_RGBA
+#endif
+
+#ifndef GL_TEXTURE_3D
+#define GL_TEXTURE_3D 0x806F
+#endif
+
+#ifndef GL_RGB16
+#define GL_RGB16 0x8054
+#endif
+
+void tst_QGL::fboFormat()
+{
+ // Check the initial conditions.
+ QGLFramebufferObjectFormat format1;
+ QCOMPARE(format1.samples(), 0);
+ QVERIFY(format1.attachment() == QGLFramebufferObject::NoAttachment);
+ QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_2D));
+ QCOMPARE(int(format1.internalTextureFormat()), int(DEFAULT_FORMAT));
+
+ // Modify the values and re-check.
+ format1.setSamples(8);
+ format1.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
+ format1.setTextureTarget(GL_TEXTURE_3D);
+ format1.setInternalTextureFormat(GL_RGB16);
+ QCOMPARE(format1.samples(), 8);
+ QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D));
+ QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16));
+
+ // Make copies and check that they are the same.
+ QGLFramebufferObjectFormat format2(format1);
+ QGLFramebufferObjectFormat format3;
+ QCOMPARE(format2.samples(), 8);
+ QVERIFY(format2.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(int(format2.textureTarget()), int(GL_TEXTURE_3D));
+ QCOMPARE(int(format2.internalTextureFormat()), int(GL_RGB16));
+ format3 = format1;
+ QCOMPARE(format3.samples(), 8);
+ QVERIFY(format3.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(int(format3.textureTarget()), int(GL_TEXTURE_3D));
+ QCOMPARE(int(format3.internalTextureFormat()), int(GL_RGB16));
+
+ // Modify the copies and check that the original is unchanged.
+ format2.setSamples(9);
+ format3.setTextureTarget(GL_TEXTURE_2D);
+ QCOMPARE(format1.samples(), 8);
+ QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil);
+ QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D));
+ QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16));
+}
+
QTEST_MAIN(tst_QGL)
#include "tst_qgl.moc"