From 02be3fef951575475da44301af353097c42787d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sun, 18 Feb 2018 20:54:28 +0200 Subject: [PATCH] libgui|Image: 16-bit floating point image formats --- doomsday/libs/gui/include/de/graphics/image.h | 28 ++++++---- doomsday/libs/gui/src/graphics/image.cpp | 55 +++++++++++-------- 2 files changed, 47 insertions(+), 36 deletions(-) diff --git a/doomsday/libs/gui/include/de/graphics/image.h b/doomsday/libs/gui/include/de/graphics/image.h index e53f41a99a..8cf9198541 100644 --- a/doomsday/libs/gui/include/de/graphics/image.h +++ b/doomsday/libs/gui/include/de/graphics/image.h @@ -65,18 +65,22 @@ class LIBGUI_PUBLIC Image : public ISerializable RGBA_5551 = 9, RGBA_8888 = 10, RGBx_8888 = 11, ///< 32-bit depth, alpha data ignored. - R_32f = 12, - RG_32f = 13, - RGB_32f = 14, - RGBA_32f = 15, - R_32i = 16, - RG_32i = 17, - RGB_32i = 18, - RGBA_32i = 19, - R_32ui = 20, - RG_32ui = 21, - RGB_32ui = 22, - RGBA_32ui = 23, + R_16f = 12, + RG_16f = 13, + RGB_16f = 14, + RGBA_16f = 15, + R_32f = 16, + RG_32f = 17, + RGB_32f = 18, + RGBA_32f = 19, + R_32i = 20, + RG_32i = 21, + RGB_32i = 22, + RGBA_32i = 23, + R_32ui = 24, + RG_32ui = 25, + RGB_32ui = 26, + RGBA_32ui = 27, }; typedef Vector2ui Size; diff --git a/doomsday/libs/gui/src/graphics/image.cpp b/doomsday/libs/gui/src/graphics/image.cpp index 317846e56b..267f6ff503 100644 --- a/doomsday/libs/gui/src/graphics/image.cpp +++ b/doomsday/libs/gui/src/graphics/image.cpp @@ -333,10 +333,10 @@ using namespace internal; DENG2_PIMPL(Image) { - Format format; - Size size; - QImage image; - Block pixels; + Format format; + Size size; + QImage image; + Block pixels; ByteRefArray refPixels; float pointRatio = 1.f; @@ -423,48 +423,43 @@ int Image::depth() const { switch (d->format) { - case UseQImageFormat: - return d->image.depth(); + case UseQImageFormat: return d->image.depth(); case Luminance_8: - case Alpha_8: - return 8; + case Alpha_8: return 8; case LuminanceAlpha_88: case RGB_565: case RGBA_4444: - case RGBA_5551: - return 16; + case RGBA_5551: return 16; - case RGB_888: - return 24; + case RGB_888: return 24; case RGBA_8888: - case RGBx_8888: - return 32; + case RGBx_8888: return 32; + + case R_16f: return 16; + case RG_16f: return 32; + case RGB_16f: return 48; + case RGBA_16f: return 64; case R_32f: case R_32i: - case R_32ui: - return 32; + case R_32ui: return 32; case RG_32f: case RG_32i: - case RG_32ui: - return 64; + case RG_32ui: return 64; case RGB_32f: case RGB_32i: - case RGB_32ui: - return 96; + case RGB_32ui: return 96; case RGBA_32f: case RGBA_32i: - case RGBA_32ui: - return 128; + case RGBA_32ui: return 128; - default: - return 0; + default: return 0; } } @@ -821,6 +816,18 @@ GLPixelFormat Image::glFormat(Format imageFormat) case RGBx_8888: return GLPixelFormat(GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 4); + case R_16f: + return GLPixelFormat(GL_R16F, GL_RED, GL_FLOAT, 2); + + case RG_16f: + return GLPixelFormat(GL_RG16F, GL_RG, GL_FLOAT, 4); + + case RGB_16f: + return GLPixelFormat(GL_RGB16F, GL_RGB, GL_FLOAT, 2); + + case RGBA_16f: + return GLPixelFormat(GL_RGBA16F, GL_RGBA, GL_FLOAT, 4); + case R_32f: return GLPixelFormat(GL_R32F, GL_RED, GL_FLOAT, 4);