Browse Source

GL: add ES-only TextureFormat::BGRA[8].

And clarify their purpose. This was an accidental ommision, as there's
no need for such a thing on desktop.
findsdl-include-root
Vladimír Vondruš 7 years ago
parent
commit
3f9c541753
  1. 2
      doc/changelog.dox
  2. 12
      src/Magnum/GL/AbstractTexture.cpp
  3. 14
      src/Magnum/GL/PixelFormat.h
  4. 4
      src/Magnum/GL/TextureFormat.cpp
  5. 45
      src/Magnum/GL/TextureFormat.h

2
doc/changelog.dox

@ -123,6 +123,8 @@ See also:
@gl_extension{EXT,texture_sRGB_RG8} extensions adding
@ref GL::TextureFormat::SR8 and @ref GL::TextureFormat::SRG8 formats to
complement new sRGB formats in @ref GL::PixelFormat
- Added ES-only @ref GL::TextureFormat::BGRA and @ref GL::TextureFormat::BGRA8
and clarified their purpose in relation to @ref GL::PixelFormat::BGRA
- New @ref GL::AbstractFramebuffer::implementationColorReadFormat() and
@ref GL::AbstractFramebuffer::implementationColorReadType() queries for
more robust checks when doing framebuffer readbacks; together with three

12
src/Magnum/GL/AbstractTexture.cpp

@ -821,6 +821,12 @@ PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) {
return PixelFormat::SRGBAlpha;
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
case TextureFormat::BGRA:
case TextureFormat::BGRA8:
return PixelFormat::BGRA;
#endif
#ifndef MAGNUM_TARGET_GLES2
case TextureFormat::RGBA8UI:
case TextureFormat::RGBA8I:
@ -919,6 +925,12 @@ PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) {
#endif
#ifndef MAGNUM_TARGET_GLES
case TextureFormat::RGBA2: /**< @todo really? */
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
case TextureFormat::BGRA:
case TextureFormat::BGRA8:
#endif
#ifndef MAGNUM_TARGET_GLES
case TextureFormat::CompressedRed:
case TextureFormat::CompressedRG:
case TextureFormat::CompressedRGB:

14
src/Magnum/GL/PixelFormat.h

@ -143,16 +143,22 @@ enum class PixelFormat: GLenum {
#ifndef MAGNUM_TARGET_GLES
/**
* Floating-point BGR.
* @requires_gl Only RGB component ordering is available in OpenGL ES and
* WebGL.
* Floating-point BGR. On desktop OpenGL there's no corresponding dedicated
* texture format for BGR(A) --- simply use it with @ref TextureFormat::RGB8.
* @requires_gl For three-component formats, only RGB component ordering is
* available in OpenGL ES and WebGL. See @ref PixelFormat::BGRA for an
* alternative.
*/
BGR = GL_BGR,
#endif
#ifndef MAGNUM_TARGET_WEBGL
/**
* Floating-point BGRA.
* Floating-point BGRA. On desktop OpenGL there's no corresponding
* dedicated texture format for BGR(A) --- simply use it with
* @ref TextureFormat::RGBA8. On OpenGL ES however, you're required to
* use @ref TextureFormat::BGRA8 (which is on the other hand not defined
* for desktop OpenGL).
* @requires_es_extension Extension @gl_extension{EXT,read_format_bgra}
* for framebuffer reading, extension @gl_extension{APPLE,texture_format_BGRA8888}
* or @gl_extension{EXT,texture_format_BGRA8888} for texture data.

4
src/Magnum/GL/TextureFormat.cpp

@ -163,6 +163,10 @@ Debug& operator<<(Debug& debug, const TextureFormat value) {
#ifndef MAGNUM_TARGET_GLES
_c(RGBA12)
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
_c(BGRA)
_c(BGRA8)
#endif
#ifndef MAGNUM_TARGET_GLES
_c(CompressedRed)
_c(CompressedRG)

45
src/Magnum/GL/TextureFormat.h

@ -129,7 +129,9 @@ enum class TextureFormat: GLenum {
/**
* RGB, type/size implementation-dependent. Not allowed in unemulated
* @ref Texture::setStorage() "*Texture::setStorage()" calls, in
* that case use @ref TextureFormat::RGB8 "TextureFormat::RGB8" instead.
* that case use @ref TextureFormat::RGB8 "TextureFormat::RGB8" instead. On
* desktop OpenGL this format is meant to be used for
* @ref PixelFormat::BGR as well.
* @requires_gl Can't be used as a render target in OpenGL ES or WebGL. See
* @ref TextureFormat::RGBA for an alternative.
* @deprecated_gl Prefer to use the exactly specified version of this
@ -142,7 +144,8 @@ enum class TextureFormat: GLenum {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
/**
* RGB, each component normalized unsigned byte.
* RGB, each component normalized unsigned byte. On desktop OpenGL this
* format is meant to be used for @ref PixelFormat::BGRA as well.
* @requires_gles30 Extension @gl_extension{OES,required_internalformat}
* (for image specification) or @gl_extension{EXT,texture_storage}
* (for texture storage) in OpenGL ES 2.0. Use @ref TextureFormat::RGB
@ -160,7 +163,10 @@ enum class TextureFormat: GLenum {
/**
* RGBA, type/size implementation-dependent. Not allowed in unemulated
* @ref Texture::setStorage() "*Texture::setStorage()" calls, in that case
* use @ref TextureFormat::RGBA8 "TextureFormat::RGBA8" instead.
* use @ref TextureFormat::RGBA8 "TextureFormat::RGBA8" instead. On desktop
* OpenGL this format is meant to be used for @ref PixelFormat::BGRA as
* well, however on OpenGL ES you're required to use
* @ref TextureFormat::BGRA for BGRA pixel formats.
* @deprecated_gl Prefer to use the exactly specified version of this
* format, e.g. @ref TextureFormat::RGBA8.
* @requires_webgl20 Extension @webgl_extension{OES,texture_half_float_linear}
@ -171,7 +177,10 @@ enum class TextureFormat: GLenum {
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
/**
* RGBA, each component normalized unsigned byte.
* RGBA, each component normalized unsigned byte. On desktop OpenGL this
* format is meant to be used with @ref PixelFormat::BGRA as well, however
* on OpenGL ES you're required to use @ref TextureFormat::BGRA8 for BGRA
* pixel formats.
* @requires_gles30 Extension @gl_extension{OES,required_internalformat}
* (for image specification) or @gl_extension{EXT,texture_storage}
* (for texture storage) in OpenGL ES 2.0. Use @ref TextureFormat::RGBA
@ -1018,6 +1027,34 @@ enum class TextureFormat: GLenum {
RGBA12 = GL_RGBA12,
#endif
#if defined(DOXYGEN_GENERATING_OUTPUT) || (defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL))
/**
* BGRA, type/size implementation-dependent. Not allowed in unemulated
* @ref Texture::setStorage() "*Texture::setStorage()" calls, in that case
* use @ref TextureFormat::RGBA8 "TextureFormat::RGBA8" instead.
* @deprecated_gl Prefer to use the exactly specified version of this
* format, e.g. @ref TextureFormat::BGRA8.
* @requires_gles Not available on desktop OpenGL -- there it's perfectly
* legal to use @ref TextureFormat::RGBA in combination with
* @ref PixelFormat::BGRA.
* @requires_es_extension Extension @gl_extension{APPLE,texture_format_BGRA8888}
* or @gl_extension{EXT,texture_format_BGRA8888}
* @requires_gles Only RGBA component ordering is available in WebGL.
*/
BGRA = GL_BGRA_EXT,
/**
* BGRA, each component normalized unsigned byte.
* @requires_gles Not available on desktop OpenGL -- there it's perfectly
* legal to use @ref TextureFormat::RGBA8 in combination with
* @ref PixelFormat::BGRA.
* @requires_es_extension Extension @gl_extension{APPLE,texture_format_BGRA8888}. There are no signed
* normalized, integral or floating-point types with BGRA ordering.
* @requires_gles Only RGBA component ordering is available in WebGL.
*/
BGRA8 = GL_BGRA8_EXT,
#endif
#ifndef MAGNUM_TARGET_GLES
/**
* Compressed red channel, normalized unsigned. **Not available on

Loading…
Cancel
Save