summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2013-12-30 14:37:22 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-07 13:04:18 +0100
commitdcbb16a45212d263496df1e5875da6205e4f5f53 (patch)
tree8cddf5be14b99710b4632a9cce99385e588c6e49 /tests/auto/gui
parentb12b1ddf4880a5157b5edac05e0ef381e9148aae (diff)
Add takeTexture() to QOpenGLFramebufferObject
Add an API that allows to retrieve and detach the texture from the framebuffer object. The next bind() call will then create and attach a new texture. [ChangeLog][QtGui][QOpenGLFramebufferObject] Added takeTexture() for retrieving and detaching the texture from the framebuffer object. Task-number: QTBUG-35881 Change-Id: I2cca37f5872c1685b1238047f8b912e6534ab781 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index 4defbe181f..e39380a095 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -66,6 +66,8 @@ private slots:
void multiGroupSharedResourceCleanupCustom();
void fboSimpleRendering_data();
void fboSimpleRendering();
+ void fboTextureOwnership_data();
+ void fboTextureOwnership();
void fboRendering_data();
void fboRendering();
void fboHandleNulledAfterContextDestroyed();
@@ -429,6 +431,54 @@ void tst_QOpenGL::fboSimpleRendering()
delete fbo;
}
+void tst_QOpenGL::fboTextureOwnership_data()
+{
+ common_data();
+}
+
+void tst_QOpenGL::fboTextureOwnership()
+{
+ QFETCH(int, surfaceClass);
+ QScopedPointer<QSurface> surface(createSurface(surfaceClass));
+
+ QOpenGLContext ctx;
+ QVERIFY(ctx.create());
+
+ ctx.makeCurrent(surface.data());
+
+ if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
+ QSKIP("QOpenGLFramebufferObject not supported on this platform");
+
+ QOpenGLFramebufferObjectFormat fboFormat;
+ fboFormat.setAttachment(QOpenGLFramebufferObject::NoAttachment);
+
+ QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(200, 100, fboFormat);
+ QVERIFY(fbo->texture() != 0);
+ fbo->bind();
+
+ // pull out the texture
+ GLuint texture = fbo->takeTexture();
+ QVERIFY(texture != 0);
+ QVERIFY(fbo->texture() == 0);
+
+ // verify that the next bind() creates a new texture
+ fbo->bind();
+ QVERIFY(fbo->texture() != 0 && fbo->texture() != texture);
+
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glFinish();
+
+ QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
+ QImage reference(fb.size(), QImage::Format_RGB32);
+ reference.fill(0xffff0000);
+
+ QFUZZY_COMPARE_IMAGES(fb, reference);
+
+ glDeleteTextures(1, &texture);
+ delete fbo;
+}
+
void tst_QOpenGL::fboRendering_data()
{
common_data();