From 5a2547dd40cc1a37ad55c7dabd70263c0d6e9692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 25 Aug 2019 18:36:22 +0200 Subject: [PATCH] GL: clarify use of sRGB formats on ES. --- src/Magnum/GL/AbstractTexture.cpp | 6 ++++-- src/Magnum/GL/RenderbufferFormat.h | 4 ++++ src/Magnum/GL/Test/TextureGLTest.cpp | 10 +++------- src/Magnum/GL/TextureFormat.h | 13 +++---------- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index 8290d9b34..f4398afaf 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -658,7 +658,7 @@ PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) { #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) case TextureFormat::SRGB: #endif - #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::SRGB8: #endif #ifndef MAGNUM_TARGET_GLES2 @@ -838,8 +838,10 @@ PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) { case TextureFormat::SRGB: case TextureFormat::SRGBAlpha: #endif - #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::SRGB8: + #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::SRGB8Alpha8: #endif #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/GL/RenderbufferFormat.h b/src/Magnum/GL/RenderbufferFormat.h index 9d73ad845..08d59ae99 100644 --- a/src/Magnum/GL/RenderbufferFormat.h +++ b/src/Magnum/GL/RenderbufferFormat.h @@ -514,6 +514,10 @@ enum class RenderbufferFormat: GLenum { RGB10A2UI = GL_RGB10_A2UI, #endif + /* NV_sRGB_formats makes GL_SRGB8_NV accepted here but since that format + doesn't make sense anywhere else and there's GL_SRGB8_ALPHA8_EXT anyway, + I don't think it's worth supporting. */ + /** * sRGBA, each component normalized unsigned byte. * @requires_gles30 Extension @gl_extension{EXT,sRGB} in OpenGL ES 2.0. diff --git a/src/Magnum/GL/Test/TextureGLTest.cpp b/src/Magnum/GL/Test/TextureGLTest.cpp index e32088491..07606b371 100644 --- a/src/Magnum/GL/Test/TextureGLTest.cpp +++ b/src/Magnum/GL/Test/TextureGLTest.cpp @@ -2906,15 +2906,11 @@ void TextureGLTest::srgbStorage() { MAGNUM_VERIFY_NO_GL_ERROR(); - texture.setStorage(1, - #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) - TextureFormat::SRGB8, - #else - TextureFormat::SRGB, - #endif - Vector2i{32}); + #ifndef MAGNUM_TARGET_GLES2 + texture.setStorage(1, TextureFormat::SRGB8, Vector2i{32}); MAGNUM_VERIFY_NO_GL_ERROR(); + #endif } void TextureGLTest::srgbAlphaStorage() { diff --git a/src/Magnum/GL/TextureFormat.h b/src/Magnum/GL/TextureFormat.h index 44a7b0833..894419e78 100644 --- a/src/Magnum/GL/TextureFormat.h +++ b/src/Magnum/GL/TextureFormat.h @@ -863,22 +863,15 @@ enum class TextureFormat: GLenum { #endif #endif - #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + #ifndef MAGNUM_TARGET_GLES2 /** * sRGB, each component normalized unsigned byte. - * @requires_gles30 Extension @gl_extension{EXT,sRGB} and - * @gl_extension{EXT,texture_storage}, only for - * @ref Texture::setStorage() "*Texture::setStorage()" calls, - * otherwise use @ref TextureFormat::SRGB in OpenGL ES 2.0 instead. + * @requires_gles30 Use @ref TextureFormat::SRGB in OpenGL ES 2.0 instead. * @requires_gl Can't be used as render target in OpenGL ES. Use * @ref TextureFormat::SRGB8Alpha8 instead. * @requires_webgl20 Use @ref TextureFormat::SRGB in WebGL 1.0 instead. */ - #ifndef MAGNUM_TARGET_GLES2 - SRGB8 = GL_SRGB8, - #else - SRGB8 = 0x8C41, /* Not in any spec, but seems to work at least on NV */ - #endif + SRGB8 = GL_SRGB8, /* NV_sRGB_formats has this on ES2, but meh */ #endif #ifndef MAGNUM_TARGET_GLES