summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglframebufferobject.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-30 15:51:32 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-06-06 10:48:36 +0000
commit8c33b798237b95d37fe4d60ae36f0d8067504429 (patch)
treedbe16fe8ad0679791c13479ffc70e723f2f6de41 /src/gui/opengl/qopenglframebufferobject.cpp
parentafdb675ada5b21216dd1bf017a6054cf508be0b9 (diff)
Fix HDR format in QOpenGLFramebufferObject::toImage()
If the fbo had samples > 0 set, it would use a temporary fbo with a default configuration losing the HDR precision. Change-Id: I7e9966165b3100f148c4ad24738f3ee71273f29a Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/opengl/qopenglframebufferobject.cpp')
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp7
1 files changed, 5 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);
}