From 93cd9130d6d8d30e901dd3b2f2546dbc63754e2e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 18 May 2018 17:03:58 +0200 Subject: Introduce float QImage formats and rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Useful for some HDR representations and HDR rendering. Change-Id: If6e8a661faa3d2afdf17b6ed4d8ff5c5b2aeb30e Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø Reviewed-by: Lars Knoll --- src/opengl/qopengltextureuploader.cpp | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/opengl/qopengltextureuploader.cpp') diff --git a/src/opengl/qopengltextureuploader.cpp b/src/opengl/qopengltextureuploader.cpp index 469ddc56c17..488baf32add 100644 --- a/src/opengl/qopengltextureuploader.cpp +++ b/src/opengl/qopengltextureuploader.cpp @@ -45,6 +45,10 @@ #include #include +#ifndef GL_HALF_FLOAT +#define GL_HALF_FLOAT 0x140B +#endif + #ifndef GL_RED #define GL_RED 0x1903 #endif @@ -81,6 +85,14 @@ #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #endif +#ifndef GL_RGBA16F +#define GL_RGBA16F 0x881A +#endif + +#ifndef GL_RGBA32F +#define GL_RGBA32F 0x8814 +#endif + #ifndef GL_TEXTURE_SWIZZLE_R #define GL_TEXTURE_SWIZZLE_R 0x8E42 #endif @@ -236,6 +248,25 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag pixelType = GL_UNSIGNED_SHORT; targetFormat = image.format(); break; + case QImage::Format_RGBX16FPx4: + case QImage::Format_RGBA16FPx4: + case QImage::Format_RGBA16FPx4_Premultiplied: + if (context->format().majorVersion() >= 3) { + externalFormat = GL_RGBA; + internalFormat = GL_RGBA16F; + pixelType = GL_HALF_FLOAT; + targetFormat = image.format(); + } + break; + case QImage::Format_RGBX32FPx4: + case QImage::Format_RGBA32FPx4: + case QImage::Format_RGBA32FPx4_Premultiplied: + externalFormat = internalFormat = GL_RGBA; + if (context->format().majorVersion() >= 3) + internalFormat = GL_RGBA32F; + pixelType = GL_FLOAT; + targetFormat = image.format(); + break; case QImage::Format_Indexed8: if (sRgbBinding) { // Always needs conversion @@ -333,6 +364,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag targetFormat = QImage::Format_RGBA8888_Premultiplied; else if (targetFormat == QImage::Format_RGBA64) targetFormat = QImage::Format_RGBA64_Premultiplied; + else if (targetFormat == QImage::Format_RGBA16FPx4) + targetFormat = QImage::Format_RGBA16FPx4_Premultiplied; + else if (targetFormat == QImage::Format_RGBA32FPx4) + targetFormat = QImage::Format_RGBA32FPx4_Premultiplied; } else { if (targetFormat == QImage::Format_ARGB32_Premultiplied) targetFormat = QImage::Format_ARGB32; @@ -340,6 +375,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag targetFormat = QImage::Format_RGBA8888; else if (targetFormat == QImage::Format_RGBA64_Premultiplied) targetFormat = QImage::Format_RGBA64; + else if (targetFormat == QImage::Format_RGBA16FPx4_Premultiplied) + targetFormat = QImage::Format_RGBA16FPx4; + else if (targetFormat == QImage::Format_RGBA32FPx4_Premultiplied) + targetFormat = QImage::Format_RGBA32FPx4; } if (sRgbBinding) { -- cgit v1.2.3