summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2016-08-29 12:33:18 +0300
committerAntti Määttä <antti.maatta@qt.io>2016-10-21 11:10:12 +0000
commit6e8e228852f0930638b0e0272509809a0fb9ab42 (patch)
treed70c9986d714175a439d66af042449b7df865b32
parentaaf18f4ad42ad63d309e04559b4e304fd1472638 (diff)
More supported formats for read framebufferv5.8.0-beta1
Add more more supported formats to readFramebuffer function Change-Id: I4e11d8312f7c18383e4d4bf24aa4bfbf051e5ce8 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp
index 281488b47..25c1344f3 100644
--- a/src/render/graphicshelpers/graphicscontext.cpp
+++ b/src/render/graphicshelpers/graphicscontext.cpp
@@ -214,10 +214,10 @@ void GraphicsContext::resolveRenderTargetFormat()
const uint bits = RGBA_BITS(r,g,b,a);
switch (bits) {
case RGBA_BITS(8,8,8,8):
- m_renderTargetFormat = QAbstractTexture::RGBA8U;
+ m_renderTargetFormat = QAbstractTexture::RGBA8_UNorm;
break;
case RGBA_BITS(8,8,8,0):
- m_renderTargetFormat = QAbstractTexture::RGB8U;
+ m_renderTargetFormat = QAbstractTexture::RGB8_UNorm;
break;
case RGBA_BITS(5,6,5,0):
m_renderTargetFormat = QAbstractTexture::R5G6B5;
@@ -1604,12 +1604,20 @@ QImage GraphicsContext::readFramebuffer(QSize size)
const unsigned int area = size.width() * size.height();
unsigned int bytes;
GLenum format, type;
- GLenum internalFormat;
QImage::Format imageFormat;
uint stride;
+#ifndef QT_OPENGL_ES_2
+ /* format value should match GL internalFormat */
+ GLenum internalFormat = m_renderTargetFormat;
+#endif
+
switch (m_renderTargetFormat) {
+ case QAbstractTexture::RGBAFormat:
+ case QAbstractTexture::RGBA8_SNorm:
+ case QAbstractTexture::RGBA8_UNorm:
case QAbstractTexture::RGBA8U:
+ case QAbstractTexture::SRGB8_Alpha8:
#ifdef QT_OPENGL_ES_2
format = GL_RGBA;
imageFormat = QImage::Format_RGBA8888_Premultiplied;
@@ -1622,6 +1630,8 @@ QImage GraphicsContext::readFramebuffer(QSize size)
bytes = area * 4;
stride = size.width() * 4;
break;
+ case QAbstractTexture::SRGB8:
+ case QAbstractTexture::RGBFormat:
case QAbstractTexture::RGB8U:
#ifdef QT_OPENGL_ES_2
format = GL_RGBA;
@@ -1636,6 +1646,20 @@ QImage GraphicsContext::readFramebuffer(QSize size)
stride = size.width() * 4;
break;
#ifndef QT_OPENGL_ES_2
+ case QAbstractTexture::RG11B10F:
+ bytes = area * 4;
+ format = GL_RGB;
+ type = GL_UNSIGNED_INT_10F_11F_11F_REV;
+ imageFormat = QImage::Format_RGB30;
+ stride = size.width() * 4;
+ break;
+ case QAbstractTexture::RGB10A2:
+ bytes = area * 4;
+ format = GL_RGBA;
+ type = GL_UNSIGNED_INT_2_10_10_10_REV;
+ imageFormat = QImage::Format_A2BGR30_Premultiplied;
+ stride = size.width() * 4;
+ break;
case QAbstractTexture::R5G6B5:
bytes = area * 2;
format = GL_RGB;
@@ -1644,10 +1668,13 @@ QImage GraphicsContext::readFramebuffer(QSize size)
imageFormat = QImage::Format_RGB16;
stride = size.width() * 2;
break;
+ case QAbstractTexture::RGBA16F:
+ case QAbstractTexture::RGBA16U:
case QAbstractTexture::RGBA32F:
+ case QAbstractTexture::RGBA32U:
bytes = area * 16;
format = GL_RGBA;
- type = GL_RGBA32F;
+ type = GL_FLOAT;
imageFormat = QImage::Format_ARGB32_Premultiplied;
stride = size.width() * 16;
break;