Browse Source

GL: clarify use of sRGB formats on ES.

pull/370/head
Vladimír Vondruš 7 years ago
parent
commit
5a2547dd40
  1. 6
      src/Magnum/GL/AbstractTexture.cpp
  2. 4
      src/Magnum/GL/RenderbufferFormat.h
  3. 10
      src/Magnum/GL/Test/TextureGLTest.cpp
  4. 13
      src/Magnum/GL/TextureFormat.h

6
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

4
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.

10
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() {

13
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

Loading…
Cancel
Save