diff options
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 7 | ||||
-rw-r--r-- | tests/auto/other/lancelot/tst_lancelot.cpp | 18 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 469f019a1c..91c25184b6 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1424,14 +1424,17 @@ QImage QOpenGLFramebufferObject::toImage(bool flipped, int colorAttachmentIndex) // qt_gl_read_framebuffer doesn't work on a multisample FBO if (format().samples() != 0) { QRect rect(QPoint(0, 0), size()); + QOpenGLFramebufferObjectFormat fmt; if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) { - QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, QOpenGLFramebufferObjectFormat()); + fmt.setInternalTextureFormat(d->colorAttachments[colorAttachmentIndex].internalFormat); + QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, fmt); blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect, GL_COLOR_BUFFER_BIT, GL_NEAREST, colorAttachmentIndex, 0); image = temp.toImage(flipped); } else { - QOpenGLFramebufferObject temp(size(), QOpenGLFramebufferObjectFormat()); + fmt.setInternalTextureFormat(d->colorAttachments[0].internalFormat); + QOpenGLFramebufferObject temp(size(), fmt); blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect); image = temp.toImage(flipped); } diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp index 79d0f7c6cf..15267d256e 100644 --- a/tests/auto/other/lancelot/tst_lancelot.cpp +++ b/tests/auto/other/lancelot/tst_lancelot.cpp @@ -39,6 +39,10 @@ #include <algorithm> +#ifndef GL_RGB10 +#define GL_RGB10 0x8052 +#endif + class tst_Lancelot : public QObject { Q_OBJECT @@ -85,6 +89,8 @@ private slots: #ifndef QT_NO_OPENGL void testOpenGL_data(); void testOpenGL(); + void testOpenGLBGR30_data(); + void testOpenGLBGR30(); void testCoreOpenGL_data(); void testCoreOpenGL(); private: @@ -279,6 +285,16 @@ void tst_Lancelot::testOpenGL() runTestSuite(OpenGL, QImage::Format_RGB32); } +void tst_Lancelot::testOpenGLBGR30_data() +{ + tst_Lancelot::testOpenGL_data(); +} + +void tst_Lancelot::testOpenGLBGR30() +{ + runTestSuite(OpenGL, QImage::Format_BGR30); +} + void tst_Lancelot::testCoreOpenGL_data() { if (!checkSystemCoreGLSupport()) @@ -329,6 +345,8 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co QOpenGLFramebufferObjectFormat fmt; fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); fmt.setSamples(4); + if (format == QImage::Format_BGR30) + fmt.setInternalTextureFormat(GL_RGB10); QOpenGLContext ctx; ctx.setFormat(contextFormat); QVERIFY(ctx.create()); |