From 9153bcd957d5c51f249fe6fcfa560023e2b57151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 2 Nov 2012 17:39:28 +0100 Subject: [PATCH] Internal texture and renderbuffer format rework. Got rid of InternalFormat class, now it is all in one big enum, as each version (desktop, ES2, ES3) has different requirements and it can't be done that way anymore (moreover that was terribly ugly solution). --- src/AbstractTexture.cpp | 77 +--- src/AbstractTexture.h | 919 ++++++++++++++++++++++++++++------------ src/BufferedTexture.cpp | 36 +- src/BufferedTexture.h | 160 ++++--- src/Renderbuffer.cpp | 57 --- src/Renderbuffer.h | 516 +++++++++++++++++----- 6 files changed, 1154 insertions(+), 611 deletions(-) diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp index dedbd221c..9be1738fb 100644 --- a/src/AbstractTexture.cpp +++ b/src/AbstractTexture.cpp @@ -227,22 +227,22 @@ void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLfloat void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { bindInternal(); - glTexImage1D(target, mipLevel, internalFormat, size[0], 0, static_cast(components), static_cast(type), data); + glTexImage1D(target, mipLevel, static_cast(internalFormat), size[0], 0, static_cast(components), static_cast(type), data); } void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Math::Vector<1, GLsizei>& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { - glTextureImage1DEXT(_id, target, mipLevel, internalFormat, size[0], 0, static_cast(components), static_cast(type), data); + glTextureImage1DEXT(_id, target, mipLevel, GLint(internalFormat), size[0], 0, static_cast(components), static_cast(type), data); } #endif void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { bindInternal(); - glTexImage2D(target, mipLevel, internalFormat, size.x(), size.y(), 0, static_cast(components), static_cast(type), data); + glTexImage2D(target, mipLevel, GLint(internalFormat), size.x(), size.y(), 0, static_cast(components), static_cast(type), data); } #ifndef MAGNUM_TARGET_GLES void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector2i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { - glTextureImage2DEXT(_id, target, mipLevel, internalFormat, size.x(), size.y(), 0, static_cast(components), static_cast(type), data); + glTextureImage2DEXT(_id, target, mipLevel, GLint(internalFormat), size.x(), size.y(), 0, static_cast(components), static_cast(type), data); } #endif @@ -250,7 +250,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, bindInternal(); /** @todo Get some extension wrangler instead to avoid linker errors to glTexImage3D() on ES2 */ #ifndef MAGNUM_TARGET_GLES2 - glTexImage3D(target, mipLevel, internalFormat, size.x(), size.y(), size.z(), 0, static_cast(components), static_cast(type), data); + glTexImage3D(target, mipLevel, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast(components), static_cast(type), data); #else static_cast(target); static_cast(mipLevel); @@ -264,7 +264,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint mipLevel, #ifndef MAGNUM_TARGET_GLES void AbstractTexture::imageImplementationDSA(GLenum target, GLint mipLevel, InternalFormat internalFormat, const Vector3i& size, AbstractImage::Components components, AbstractImage::ComponentType type, const GLvoid* data) { - glTextureImage3DEXT(_id, target, mipLevel, internalFormat, size.x(), size.y(), size.z(), 0, static_cast(components), static_cast(type), data); + glTextureImage3DEXT(_id, target, mipLevel, GLint(internalFormat), size.x(), size.y(), size.z(), 0, static_cast(components), static_cast(type), data); } #endif @@ -312,71 +312,6 @@ void AbstractTexture::subImageImplementationDSA(GLenum target, GLint mipLevel, c } #endif -#ifndef MAGNUM_TARGET_GLES2 -AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components components, AbstractTexture::ComponentType type) { - #ifndef MAGNUM_TARGET_GLES - #define internalFormatSwitch(c) switch(type) { \ - case ComponentType::UnsignedByte: \ - internalFormat = GL_##c##8UI; break; \ - case ComponentType::Byte: \ - internalFormat = GL_##c##8I; break; \ - case ComponentType::UnsignedShort: \ - internalFormat = GL_##c##16UI; break; \ - case ComponentType::Short: \ - internalFormat = GL_##c##16I; break; \ - case ComponentType::UnsignedInt: \ - internalFormat = GL_##c##32UI; break; \ - case ComponentType::Int: \ - internalFormat = GL_##c##32I; break; \ - case ComponentType::Half: \ - internalFormat = GL_##c##16F; break; \ - case ComponentType::Float: \ - internalFormat = GL_##c##32F; break; \ - case ComponentType::NormalizedUnsignedByte: \ - internalFormat = GL_##c##8; break; \ - case ComponentType::NormalizedByte: \ - internalFormat = GL_##c##8_SNORM; break; \ - case ComponentType::NormalizedUnsignedShort: \ - internalFormat = GL_##c##16; break; \ - case ComponentType::NormalizedShort: \ - internalFormat = GL_##c##16_SNORM; break; \ - } - #else - #define internalFormatSwitch(c) switch(type) { \ - case ComponentType::UnsignedByte: \ - internalFormat = GL_##c##8UI; break; \ - case ComponentType::Byte: \ - internalFormat = GL_##c##8I; break; \ - case ComponentType::UnsignedShort: \ - internalFormat = GL_##c##16UI; break; \ - case ComponentType::Short: \ - internalFormat = GL_##c##16I; break; \ - case ComponentType::UnsignedInt: \ - internalFormat = GL_##c##32UI; break; \ - case ComponentType::Int: \ - internalFormat = GL_##c##32I; break; \ - case ComponentType::Half: \ - internalFormat = GL_##c##16F; break; \ - case ComponentType::Float: \ - internalFormat = GL_##c##32F; break; \ - case ComponentType::NormalizedUnsignedByte: \ - internalFormat = GL_##c##8; break; \ - case ComponentType::NormalizedByte: \ - internalFormat = GL_##c##8_SNORM; break; \ - } - #endif - if(components == Components::Red) - internalFormatSwitch(R) - else if(components == Components::RedGreen) - internalFormatSwitch(RG) - else if(components == Components::RGB) - internalFormatSwitch(RGB) - else if(components == Components::RGBA) - internalFormatSwitch(RGBA) - #undef internalFormatSwitch -} -#endif - #ifndef DOXYGEN_GENERATING_OUTPUT void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture* texture, const Array2D& wrapping) { #ifndef MAGNUM_TARGET_GLES diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 37d00b61b..d4627266d 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -126,440 +126,825 @@ class MAGNUM_EXPORT AbstractTexture { #endif }; - /** @{ @name Internal texture formats */ - - #ifndef MAGNUM_TARGET_GLES2 /** - * @brief Color components + * @brief Internal format * - * @requires_gles30 (no extension providing this functionality) + * @see @ref Texture::setData() "setData()" */ - enum class Components { + enum class InternalFormat: GLint { /** - * Red component only. Green and blue are set to `0`, alpha is set - * to `1`. - * @requires_gl30 Extension @extension{ARB,texture_rg} + * Red component, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this + * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::R8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} */ - Red, + #ifndef MAGNUM_TARGET_GLES2 + Red = GL_RED, + #else + Red = GL_RED_EXT, + #endif + #ifndef MAGNUM_TARGET_GLES2 /** - * Red and green component. Blue is set to `0`, alpha is set to - * `1`. - * @requires_gl30 Extension @extension{ARB,texture_rg} + * Red component, normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::Red" + * in OpenGL ES 2.0 instead. */ - RedGreen, - - RGB, /**< Red, green and blue component. Alpha is set to `1`. */ - RGBA /**< Red, green, blue component and alpha. */ - }; + R8 = GL_R8, + #endif - /** - * @brief Type of data per each component - * - * `NormalizedUnsignedByte` and `NormalizedUnsignedShort` are the - * main ones for general usage. - * @requires_gles30 (no extension providing this functionality) - */ - enum class ComponentType { /** - * (Non-normalized) unsigned byte - * @requires_gl30 Extension @extension{EXT,texture_integer} + * Red and green component, normalized unsigned, size + * implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this + * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RG8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} */ - UnsignedByte, + #ifndef MAGNUM_TARGET_GLES2 + RG = GL_RG, + #else + RG = GL_RG_EXT, + #endif + #ifndef MAGNUM_TARGET_GLES2 /** - * (Non-normalized) byte - * @requires_gl30 Extension @extension{EXT,texture_integer} + * Red and green component, each normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RG" + * in OpenGL ES 2.0 instead. */ - Byte, + RG8 = GL_RG8, + #endif /** - * (Non-normalized) unsigned short - * @requires_gl30 Extension @extension{EXT,texture_integer} + * RGB, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this + * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB8". */ - UnsignedShort, + RGB = GL_RGB, /** - * (Non-normalized) short - * @requires_gl30 Extension @extension{EXT,texture_integer} + * RGB, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} */ - Short, + #ifndef MAGNUM_TARGET_GLES2 + RGB8 = GL_RGB8, + #else + RGB8 = GL_RGB8_OES, + #endif /** - * (Non-normalized) unsigned integer - * @requires_gl30 Extension @extension{EXT,texture_integer} + * RGBA, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this + * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGBA8". */ - UnsignedInt, + RGBA = GL_RGBA, /** - * (Non-normalized) integer - * @requires_gl30 Extension @extension{EXT,texture_integer} + * RGBA, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} */ - Int, + #ifndef MAGNUM_TARGET_GLES2 + RGBA8 = GL_RGBA8, + #else + RGBA8 = GL_RGBA8_OES, + #endif + #ifndef MAGNUM_TARGET_GLES2 /** - * Half float (16 bit) - * @requires_gl30 Extension @extension{ARB,texture_float} + * Red component, normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL + * ES 2.0. */ - Half, + R8Snorm = GL_R8_SNORM, /** - * Float (32 bit) - * @requires_gl30 Extension @extension{ARB,texture_float} + * Red and green component, each normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL + * ES 2.0. */ - Float, + RG8Snorm = GL_RG8_SNORM, /** - * Normalized unsigned byte, i.e. values from range @f$ [0; 255] @f$ - * are converted to range @f$ [0.0; 1.0] @f$. + * RGB, each component normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL + * ES 2.0. */ - NormalizedUnsignedByte, + RGB8Snorm = GL_RGB8_SNORM, /** - * Normalized signed byte, i.e. values from range @f$ [-128; 127] @f$ - * are converted to range @f$ [-1.0; 1.0] @f$. - * @requires_gl31 Extension @extension{EXT,texture_snorm} + * RGBA, each component normalized signed byte. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned formats are available in OpenGL + * ES 2.0. */ - NormalizedByte + RGBA8Snorm = GL_RGBA8_SNORM, #ifndef MAGNUM_TARGET_GLES - , + /** + * Red component, normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. + */ + R16 = GL_R16, + + /** + * Red and green component, each normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. + */ + RG16 = GL_RG16, /** - * Normalized unsigned short, i.e. values from range @f$ [0; 65536] @f$ - * are converted to range @f$ [0.0; 1.0] @f$. - * @requires_gl + * RGB, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. */ - NormalizedUnsignedShort, + RGB16 = GL_RGB16, /** - * Normalized signed short, i.e. values from range @f$ [-32768; 32767] @f$ - * are converted to range @f$ [-1.0; 1.0] @f$. - * @requires_gl - * @requires_gl31 Extension @extension{EXT,texture_snorm} + * RGBA, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. */ - NormalizedShort + RGBA16 = GL_RGBA16, #endif - }; - #endif - /** - * @brief Internal format - * - * For more information about default values for unused components and - * normalization see enums Components and ComponentType. - */ - enum class Format: GLenum { - #ifndef MAGNUM_TARGET_GLES2 /** - * One-component (red channel), unsigned normalized, probably - * 8bit. - * @requires_gl30 Extension @extension{ARB,texture_rg} - * @requires_gles30 (no extension providing this functionality) + * Red component, normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned normalized formats are available + * in OpenGL ES 2.0. */ - Red = GL_RED, + R16Snorm = GL_R16_SNORM, + + /** + * Red and green component, each normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned normalized formats are available + * in OpenGL ES 2.0. + */ + RG16Snorm = GL_RG16_SNORM, + + /** + * RGB, each component normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned normalized formats are available + * in OpenGL ES 2.0. + */ + RGB16Snorm = GL_RGB16_SNORM, + + /** + * RGBA, each component normalized signed short. + * @requires_gl31 %Extension @extension{EXT,texture_snorm} + * @requires_gles30 Only unsigned normalized formats are available + * in OpenGL ES 2.0. + */ + RGBA16Snorm = GL_RGBA16_SNORM, + + /** + * Red component, non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R8UI = GL_R8UI, + + /** + * Red and green component, each non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG8UI = GL_RG8UI, + + /** + * RGB, each component non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB8UI = GL_RGB8UI, + + /** + * RGBA, each component non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA8UI = GL_RGBA8UI, + + /** + * Red component, non-normalized signed byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R8I = GL_R8I, + + /** + * Red and green component, each non-normalized signed byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG8I = GL_RG8I, + + /** + * RGB, each component non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB8I = GL_RGB8I, + + /** + * RGBA, each component non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA8I = GL_RGBA8I, + + /** + * Red component, non-normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R16UI = GL_R16UI, + + /** + * Red and green component, each non-normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG16UI = GL_RG16UI, + + /** + * RGB, each component non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB16UI = GL_RGB16UI, + + /** + * RGBA, each component non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA16UI = GL_RGBA16UI, + + /** + * Red component, non-normalized signed short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R16I = GL_R16I, + + /** + * Red and green component, each non-normalized signed short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG16I = GL_RG16I, + + /** + * RGB, each component non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB16I = GL_RGB16I, + + /** + * RGBA, each component non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA16I = GL_RGBA16I, + + /** + * Red component, non-normalized unsigned int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R32UI = GL_R32UI, + + /** + * Red and green component, each non-normalized unsigned int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG32UI = GL_RG32UI, + + /** + * RGB, each component non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB32UI = GL_RGB32UI, + + /** + * RGBA, each component non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA32UI = GL_RGBA32UI, + + /** + * Red component, non-normalized signed int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R32I = GL_R32I, + + /** + * Red and green component, each non-normalized signed int. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG32I = GL_RG32I, + + /** + * RGB, each component non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB32I = GL_RGB32I, + + /** + * RGBA, each component non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA32I = GL_RGBA32I, + + /** + * Red component, half float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R16F = GL_R16F, + + /** + * Red and green component, each half float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG16F = GL_RG16F, + + /** + * RGB, each component half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB16F = GL_RGB16F, + + /** + * RGBA, each component half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA16F = GL_RGBA16F, + + /** + * Red component, float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R32F = GL_R32F, /** - * Two-component (red and green channel), unsigned normalized, - * each component probably 8bit, 16bit total. - * @requires_gl30 Extension @extension{ARB,texture_rg} - * @requires_gles30 (no extension providing this functionality) + * Red and green component, each float. + * @requires_gl30 %Extension @extension{ARB,texture_rg} and + * @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. */ - RedGreen = GL_RG, + RG32F = GL_RG32F, + + /** + * RGB, each component float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB32F = GL_RGB32F, + + /** + * RGBA, each component float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA32F = GL_RGBA32F, #endif + #ifndef MAGNUM_TARGET_GLES /** - * Three-component RGB, unsigned normalized, each component - * probably 8bit, 24bit total. - * - * Prefer to use the exactly specified version of this format, in - * this case `Components::RGB|ComponentType::%NormalizedUnsignedByte`. + * RGB, normalized unsigned, red and green component 3bit, blue + * 2bit. + * @requires_gl Packed 8bit types are not available in OpenGL ES. */ - RGB = GL_RGB, + R3B3G2 = GL_R3_G3_B2, /** - * Four-component RGBA, unsigned normalized, each component - * probably 8bit, 24bit total. - * - * Prefer to use the exactly specified version of this format, in - * this case `Components::RGBA|ComponentType::%NormalizedUnsignedByte`. + * RGB, each component normalized unsigned 4bit. + * @requires_gl Packed 12bit types are not available in OpenGL ES. */ - RGBA = GL_RGBA, + RGB4 = GL_RGB4, + + /** + * RGB, each component normalized unsigned 5bit. + * @requires_gl Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB5A1" + * or @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB565" in OpenGL ES. + */ + RGB5 = GL_RGB5, + #endif + + /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is + GL_ARB_ES2_compatibility */ + #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) + /** + * RGB, normalized unsigned, red and blue component 5bit, green 6bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + */ + #ifndef MAGNUM_TARGET_GLES2 + RGB565 = GL_RGB565, + #else + RGB565 = GL_RGB565_OES, + #endif + #endif + + /** + * RGB, each component normalized unsigned 10bit. + * @requires_es_extension %Extension @es_extension{OES,required_internalformat} + */ + #ifndef MAGNUM_TARGET_GLES + RGB10 = GL_RGB10, + #else + RGB10 = GL_RGB10_EXT, + #endif #ifndef MAGNUM_TARGET_GLES /** - * Three-component BGR, unsigned normalized, each component - * probably 8bit, 24bit total. - * @requires_gl + * RGB, each component normalized unsigned 12bit. + * @requires_gl Packed 36bit types are not available in OpenGL ES. */ - BGR = GL_BGR, + RGB12 = GL_RGB12, /** - * Four-component BGRA, unsigned normalized, each component - * probably 8bit, 24bit total. - * @requires_gl + * RGBA, normalized unsigned, each component 2bit. + * @requires_gl Packed 8bit types are not available in OpenGL ES. */ - BGRA = GL_BGRA, + RGBA2 = GL_RGBA2, #endif + /** + * RGBA, normalized unsigned, each component 4bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + */ #ifndef MAGNUM_TARGET_GLES2 + RGBA4 = GL_RGBA4, + #else + RGBA4 = GL_RGBA4_OES, + #endif + /** - * Four-component sRGBA, unsigned normalized, each component - * 8bit, 32bit total. - * @requires_gles30 (no extension providing this functionality) + * RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} */ - SRGBA8 = GL_SRGB8_ALPHA8, + #ifndef MAGNUM_TARGET_GLES2 + RGB5A1 = GL_RGB5_A1, + #else + RGB5A1 = GL_RGB5_A1_OES, + #endif /** - * Three-component sRGB, unsigned normalized, each component - * 8bit, 24bit total. - * @requires_gles30 (no extension providing this functionality) + * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + * and @es_extension{EXT,texture_type_2_10_10_10_REV} */ - SRGB8 = GL_SRGB8, + #ifndef MAGNUM_TARGET_GLES2 + RGB10A2 = GL_RGB10_A2, + #else + RGB10A2 = GL_RGB10_A2_EXT, + #endif + #ifndef MAGNUM_TARGET_GLES2 /** - * Four-component RGBA, unsigned normalized, each RGB component - * 10bit, alpha 2bit, 32bit total. - * @requires_gles30 (no extension providing this functionality) + * RGBA, non-normalized unsigned, each RGB component 10bit, alpha + * 2bit. + * @requires_gl33 %Extension @extension{ARB,texture_rgb10_a2ui} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. */ - RGB10Alpha2 = GL_RGB10_A2, + RGB10A2UI = GL_RGB10_A2UI, + #endif + #ifndef MAGNUM_TARGET_GLES /** - * Four-component RGBA, unsigned non-normalized, each RGB - * component 10bit, alpha channel 2bit, 32bit total. - * @requires_gl33 Extension @extension{ARB,texture_rgb10_a2ui} - * @requires_gles30 (no extension providing this functionality) + * RGBA, each component normalized unsigned 12bit. + * @requires_gl Packed 48bit types are not available in OpenGL ES. */ - RGB10Alpha2Unsigned = GL_RGB10_A2UI, + RGBA12 = GL_RGBA12, #endif + #ifndef MAGNUM_TARGET_GLES2 /** - * Four-component RGBA, unsigned normalized, each RGB component - * 5bit, alpha 1bit, 16bit total. + * RGB, float, red and green component 11bit, blue 10bit. + * @requires_gl30 %Extension @extension{EXT,packed_float} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. */ - RGB5Alpha1 = GL_RGB5_A1, + R11FG11FB10F = GL_R11F_G11F_B10F, + #endif + #ifndef MAGNUM_TARGET_GLES2 /** - * Four-component RGBA, unsigned normalized, each component 4bit, - * 16bit total. + * RGB, unsigned with exponent, each RGB component 9bit, exponent 5bit. + * @requires_gl30 %Extension @extension{EXT,texture_shared_exponent} + * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB" + * in OpenGL ES 2.0 instead. */ - RGBA4 = GL_RGBA4, + RGB9E5 = GL_RGB9_E5, + #endif + + /** + * sRGB, normalized unsigned, size implementation-dependent. + * @todo is this allowed in core? + * @deprecated Prefer to use the exactly specified version of this + * format, i.e. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8". + * @requires_es_extension %Extension @es_extension{EXT,sRGB} in + * OpenGL ES 2.0, use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8" + * in OpenGL ES 3.0 instead. + */ + #ifndef MAGNUM_TARGET_GLES + SRGB = GL_SRGB, + #else + SRGB = GL_SRGB_EXT, + #endif #ifndef MAGNUM_TARGET_GLES2 /** - * Three-component RGB, float, red and green 11bit, blue 10bit, - * 32bit total. - * @requires_gl30 Extension @extension{EXT,packed_float} - * @requires_gles30 (no extension providing this functionality) + * sRGB, each component normalized unsigned byte. + * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB" + * in OpenGL ES 2.0 instead. */ - RG11B10Float = GL_R11F_G11F_B10F, + SRGB8 = GL_SRGB8, #endif - /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is - GL_ARB_ES2_compatibility */ - #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) /** - * Three-component RGB, unsigned normalized, red and blue 5bit, - * green 6bit, 16bit total. + * sRGBA, normalized unsigned, size implementation-dependent. + * @todo is this allowed in core? + * @deprecated Prefer to use the exactly specified version of this + * format, i.e. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8Alpha8". + * @requires_es_extension %Extension @es_extension{EXT,sRGB} in + * OpenGL ES 2.0, use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGB8Alpha8" + * in OpenGL ES 3.0 instead. */ - RGB565 = GL_RGB565 + #ifndef MAGNUM_TARGET_GLES + SRGBAlpha = GL_SRGB_ALPHA, + #else + SRGBAlpha = GL_SRGB_ALPHA_EXT, #endif #ifndef MAGNUM_TARGET_GLES2 - , /** - * Three-component RGB, unsigned with exponent, each component - * 9bit, exponent 5bit, 32bit total. - * @requires_gl30 Extension @extension{EXT,texture_shared_exponent} - * @requires_gles30 (no extension providing this functionality) + * sRGBA, each component normalized unsigned byte. + * @requires_gles30 Use @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::SRGBAlpha" + * in OpenGL ES 2.0 instead. */ - RGB9Exponent5 = GL_RGB9_E5, + SRGB8Alpha8 = GL_SRGB8_ALPHA8, #endif #ifndef MAGNUM_TARGET_GLES /** - * Compressed red channel, unsigned normalized. - * @requires_gl - * @requires_gl30 Extension @extension{ARB,texture_rg} + * Compressed red channel, normalized unsigned. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Generic texture compression is not available in + * OpenGL ES. */ CompressedRed = GL_COMPRESSED_RED, /** - * Compressed red and green channel, unsigned normalized. - * @requires_gl - * @requires_gl30 Extension @extension{ARB,texture_rg} + * Compressed red and green channel, normalized unsigned. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Generic texture compression is not available in + * OpenGL ES. */ - CompressedRedGreen = GL_COMPRESSED_RG, + CompressedRG = GL_COMPRESSED_RG, /** - * Compressed RGB, unsigned normalized. - * @requires_gl + * Compressed RGB, normalized unsigned. + * @requires_gl Generic texture compression is not available in + * OpenGL ES. */ CompressedRGB = GL_COMPRESSED_RGB, /** - * Compressed RGBA, unsigned normalized. - * @requires_gl + * Compressed RGBA, normalized unsigned. + * @requires_gl Generic texture compression is not available in + * OpenGL ES. */ CompressedRGBA = GL_COMPRESSED_RGBA, /** - * RTGC compressed red channel, unsigned normalized. - * @requires_gl - * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * RTGC compressed red channel, normalized unsigned. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in + * OpenGL ES. */ - CompressedRtgcRed = GL_COMPRESSED_RED_RGTC1, + CompressedRedRtgc1 = GL_COMPRESSED_RED_RGTC1, /** - * RTGC compressed red channel, signed normalized. - * @requires_gl - * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * RTGC compressed red and green channel, normalized unsigned. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in + * OpenGL ES. */ - CompressedRtgcSignedRed = GL_COMPRESSED_SIGNED_RED_RGTC1, + CompressedRGRgtc2 = GL_COMPRESSED_RG_RGTC2, /** - * RTGC compressed red and green channel, unsigned normalized. - * @requires_gl - * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * RTGC compressed red channel, normalized signed. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in + * OpenGL ES. */ - CompressedRtgcRedGreen = GL_COMPRESSED_RG_RGTC2, + CompressedSignedRedRgtc1 = GL_COMPRESSED_SIGNED_RED_RGTC1, /** - * RTGC compressed red and green channel, signed normalized. - * @requires_gl - * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} + * RTGC compressed red and green channel, normalized signed. + * @requires_gl30 %Extension @extension{EXT,texture_compression_rgtc} + * @requires_gl RGTC texture compression is not available in + * OpenGL ES. */ - CompressedRtgcSignedRedGreen = GL_COMPRESSED_SIGNED_RG_RGTC2, + CompressedSignedRGRgtc2 = GL_COMPRESSED_SIGNED_RG_RGTC2, /* These are named with _ARB suffix, because glcorearb.h doesn't have suffixless version (?!) and GLEW has it without suffix as late as of 1.8.0 { */ /** - * BPTC compressed RGBA, unsigned normalized. - * @requires_gl - * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * BPTC compressed RGBA, normalized unsigned. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in + * OpenGL ES. */ - CompressedBptcRGBA = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, + CompressedRGBABtpcUnorm = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, /** - * BPTC compressed sRGBA, unsigned normalized. - * @requires_gl - * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * BPTC compressed sRGBA, normalized unsigned. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in + * OpenGL ES. */ - CompressedBptcSRGBA = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, + CompressedSRGBAlphaBtpcUnorm = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, /** - * BPTC compressed RGB, signed float. - * @requires_gl - * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * BPTC compressed RGB, unsigned float. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in + * OpenGL ES. */ - CompressedBptcRGBSignedFloat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, + CompressedRGBBptcUnsignedFloat = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, /** - * BPTC compressed RGB, unsigned float. - * @requires_gl - * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} + * BPTC compressed RGB, signed float. + * @requires_gl42 %Extension @extension{ARB,texture_compression_bptc} + * @requires_gl BPTC texture compression is not available in + * OpenGL ES. */ - CompressedBptcRGBUnsignedFloat = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, + CompressedRGBBptcSignedFloat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, /*}*/ + #endif /** - * Depth component, at least 16bit. - * - * Prefer to use the exactly specified version of this format, in - * this case e.g. `Format::Depth16`. - * @requires_gl + * Depth component, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this + * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::DepthComponent16". + * @requires_gles30 %Extension @es_extension{OES,depth_texture} */ - Depth = GL_DEPTH_COMPONENT, + DepthComponent = GL_DEPTH_COMPONENT, /** - * Depth and stencil component, at least 24bit depth and 8bit - * stencil. - * - * Prefer to use the exactly specified version of this format, in - * this case e.g. `Format::Depth24Stencil8`. - * @requires_gl + * Depth and stencil component, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this + * format, e.g. @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::Depth24Stencil8". + * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} */ + #ifndef MAGNUM_TARGET_GLES2 DepthStencil = GL_DEPTH_STENCIL, + #else + DepthStencil = GL_DEPTH_STENCIL_OES, #endif - #ifndef MAGNUM_TARGET_GLES2 /** - * 16bit depth component. - * @requires_gles30 (no extension providing this functionality) + * Depth component, 16bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + * and @es_extension{OES,depth_texture} */ - Depth16 = GL_DEPTH_COMPONENT16, + DepthComponent16 = GL_DEPTH_COMPONENT16, /** - * 24bit depth component. - * @requires_gles30 (no extension providing this functionality) + * Depth component, 24bit. + * @requires_gles30 %Extension @es_extension{OES,required_internalformat}, + * @es_extension{OES,depth_texture} and @es_extension{OES,depth24} */ - Depth24 = GL_DEPTH_COMPONENT24, + #ifndef MAGNUM_TARGET_GLES2 + DepthComponent24 = GL_DEPTH_COMPONENT24, + #else + DepthComponent24 = GL_DEPTH_COMPONENT24_OES, + #endif /** - * 32bit float depth component. - * @requires_gl30 Extension @extension{ARB,depth_buffer_float} - * @requires_gles30 (no extension providing this functionality) + * Depth component, 32bit. + * @requires_es_extension %Extension @es_extension{OES,required_internalformat}, + * @es_extension{OES,depth_texture} and @es_extension{OES,depth24} */ - Depth32Float = GL_DEPTH_COMPONENT32F, + #ifndef MAGNUM_TARGET_GLES2 + DepthComponent32 = GL_DEPTH_COMPONENT32, + #else + DepthComponent32 = GL_DEPTH_COMPONENT32_OES, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Depth component, 32bit float. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in + * OpenGL ES 2.0. + */ + DepthComponent32F = GL_DEPTH_COMPONENT32F, + #endif /** * 24bit depth and 8bit stencil component. - * @requires_gl30 Extension @extension{EXT,packed_depth_stencil} - * @requires_gles30 (no extension providing this functionality) + * @requires_gl30 %Extension @extension{EXT,packed_depth_stencil} + * @requires_gles30 %Extension @es_extension{OES,required_internalformat} + * and @es_extension{OES,packed_depth_stencil} */ + #ifdef MAGNUM_TARGET_GLES2 + Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES + #else Depth24Stencil8 = GL_DEPTH24_STENCIL8, + #endif + #ifndef MAGNUM_TARGET_GLES2 /** * 32bit float depth component and 8bit stencil component. - * @requires_gl30 Extension @extension{ARB,depth_buffer_float} - * @requires_gles30 (no extension providing this functionality) + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in + * OpenGL ES 2.0. */ - Depth32FloatStencil8 = GL_DEPTH32F_STENCIL8 + Depth32FStencil8 = GL_DEPTH32F_STENCIL8 #endif }; - /** - * @brief Internal format - * - * When specifying internal format, you can either specify as binary - * OR of component count (using Component enum) and data type per - * component (value from ComponentType enum), or using one of named - * internal formats from Format enum, e.g.: - * @code - * InternalFormat fmt1 = Format::RGBA; - * InternalFormat fmt2 = Components::RGBA|ComponentType::NormalizedUnsignedByte; - * @endcode - * You can also use the constructor directly instead of binary OR: - * @code - * InternalFormat fmt2(Components::RGBA, ComponentType::NormalizedUnsignedByte); - * @endcode - */ - class MAGNUM_EXPORT InternalFormat { - public: - #ifndef MAGNUM_TARGET_GLES2 - /** - * @brief Constructor from component count and data type per component - * - * @requires_gles30 (no extension providing this functionality) - */ - InternalFormat(Components components, ComponentType type); - #endif - - /** @brief Constructor from named internal format */ - inline constexpr InternalFormat(Format format): internalFormat(static_cast(format)) {} - - /** @brief OpenGL internal format ID */ - inline constexpr operator GLint() const { return internalFormat; } - - private: - GLint internalFormat; - }; - - /*@}*/ - /** * @brief Max supported layer count * @@ -713,7 +1098,7 @@ class MAGNUM_EXPORT AbstractTexture { * @see setMinificationFilter(), @fn_gl{ActiveTexture}, * @fn_gl{BindTexture} and @fn_gl{GenerateMipmap} or * @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access} - * @requires_gl30 Extension @extension{EXT,framebuffer_object} + * @requires_gl30 %Extension @extension{EXT,framebuffer_object} */ AbstractTexture* generateMipmap(); @@ -802,24 +1187,6 @@ class MAGNUM_EXPORT AbstractTexture { GLuint _id; }; -#ifndef MAGNUM_TARGET_GLES2 -/** @relates AbstractTexture -@brief Convertor of component count and data type to InternalFormat - -@requires_gles30 (no extension providing this functionality) -*/ -inline AbstractTexture::InternalFormat operator|(AbstractTexture::Components components, AbstractTexture::ComponentType type) { - return AbstractTexture::InternalFormat(components, type); -} - -/** @relates AbstractTexture - * @overload - */ -inline AbstractTexture::InternalFormat operator|(AbstractTexture::ComponentType type, AbstractTexture::Components components) { - return AbstractTexture::InternalFormat(components, type); -} -#endif - #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_TARGET_GLES template<> struct AbstractTexture::DataHelper<1> { diff --git a/src/BufferedTexture.cpp b/src/BufferedTexture.cpp index 862f1f97a..83327903b 100644 --- a/src/BufferedTexture.cpp +++ b/src/BufferedTexture.cpp @@ -34,43 +34,11 @@ void BufferedTexture::initializeContextBasedFunctionality(Context* context) { void BufferedTexture::setBufferImplementationDefault(BufferedTexture::InternalFormat internalFormat, Buffer* buffer) { bindInternal(); - glTexBuffer(GL_TEXTURE_BUFFER, internalFormat, buffer->id()); + glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); } void BufferedTexture::setBufferImplementationDSA(BufferedTexture::InternalFormat internalFormat, Buffer* buffer) { - glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, internalFormat, buffer->id()); -} - -BufferedTexture::InternalFormat::InternalFormat(Components components, ComponentType type) { - #define internalFormatSwitch(c) switch(type) { \ - case ComponentType::UnsignedByte: \ - internalFormat = GL_##c##8UI; break; \ - case ComponentType::Byte: \ - internalFormat = GL_##c##8I; break; \ - case ComponentType::UnsignedShort: \ - internalFormat = GL_##c##16UI; break; \ - case ComponentType::Short: \ - internalFormat = GL_##c##16I; break; \ - case ComponentType::UnsignedInt: \ - internalFormat = GL_##c##32UI; break; \ - case ComponentType::Int: \ - internalFormat = GL_##c##32I; break; \ - case ComponentType::Half: \ - internalFormat = GL_##c##16F; break; \ - case ComponentType::Float: \ - internalFormat = GL_##c##32F; break; \ - case ComponentType::NormalizedUnsignedByte: \ - internalFormat = GL_##c##8; break; \ - case ComponentType::NormalizedUnsignedShort: \ - internalFormat = GL_##c##16; break; \ - } - if(components == Components::Red) - internalFormatSwitch(R) - else if(components == Components::RedGreen) - internalFormatSwitch(RG) - else if(components == Components::RGBA) - internalFormatSwitch(RGBA) - #undef internalFormatSwitch + glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer->id()); } } diff --git a/src/BufferedTexture.h b/src/BufferedTexture.h index ba2e5e4f8..cd02eff5d 100644 --- a/src/BufferedTexture.h +++ b/src/BufferedTexture.h @@ -79,75 +79,120 @@ class MAGNUM_EXPORT BufferedTexture: private AbstractTexture { BufferedTexture& operator=(BufferedTexture&& other) = delete; public: - /** @{ @name Internal buffered texture formats */ - /** - * @copybrief AbstractTexture::Components + * @brief Internal format * - * Like AbstractTexture::Components, without three-component RGB. + * @see setBuffer() */ - enum class Components { - Red, RedGreen, RGBA - }; + enum class InternalFormat: GLenum { + /** Red component, normalized unsigned byte. */ + R8 = GL_R8, - /** - * @copybrief AbstractTexture::ComponentType - * - * Like AbstractTexture::ComponentType, without normalized signed - * types. - */ - enum class ComponentType { - UnsignedByte, Byte, UnsignedShort, Short, UnsignedInt, Int, Half, - Float, NormalizedUnsignedByte, NormalizedUnsignedShort - }; + /** Red and green component, each normalized unsigned byte. */ + RG8 = GL_RG8, - /** @copybrief AbstractTexture::Format */ - enum class Format: GLenum { - /** - * Three-component RGB, float, each component 32bit, 96bit total. - * - * @requires_gl40 Extension @extension{ARB,texture_buffer_object_rgb32} - */ - RGB32Float = GL_RGB32F, + /** RGBA, each component normalized unsigned byte. */ + RGBA8 = GL_RGBA8, + + /** Red component, normalized unsigned short. */ + R16 = GL_R16, + + /** Red and green component, each normalized unsigned short. */ + RG16 = GL_RG16, + + /** RGBA, each component normalized unsigned short. */ + RGBA16 = GL_RGBA16, + + /** Red component, non-normalized unsigned byte. */ + R8UI = GL_R8UI, + + /** Red and green component, each non-normalized unsigned byte. */ + RG8UI = GL_RG8UI, + + /** RGBA, each component non-normalized unsigned byte. */ + RGBA8UI = GL_RGBA8UI, + + /** Red component, non-normalized signed byte. */ + R8I = GL_R8I, + + /** Red and green component, each non-normalized signed byte. */ + RG8I = GL_RG8I, + + /** RGBA, each component non-normalized signed byte. */ + RGBA8I = GL_RGBA8I, + + /** Red component, non-normalized unsigned short. */ + R16UI = GL_R16UI, + + /** Red and green component, each non-normalized unsigned short. */ + RG16UI = GL_RG16UI, + + /** RGBA, each component non-normalized unsigned short. */ + RGBA16UI = GL_RGBA16UI, + + /** Red component, non-normalized signed short. */ + R16I = GL_R16I, + + /** Red and green component, each non-normalized signed short. */ + RG16I = GL_RG16I, + + /** RGBA, each component non-normalized signed short. */ + RGBA16I = GL_RGBA16I, + + /** Red component, non-normalized unsigned int. */ + R32UI = GL_R32UI, + + /** Red and green component, each non-normalized unsigned int. */ + RG32UI = GL_RG32UI, /** - * Three-component RGB, unsigned non-normalized, each component - * 32bit, 96bit total. - * + * RGB, each component non-normalized unsigned int. * @requires_gl40 Extension @extension{ARB,texture_buffer_object_rgb32} */ - RGB32UnsignedInt = GL_RGB32UI, + RGB32UI = GL_RGB32UI, + + /** RGBA, each component non-normalized unsigned int. */ + RGBA32UI = GL_RGBA32UI, + + /** Red component, non-normalized signed int. */ + R32I = GL_R32I, + + /** Red and green component, each non-normalized signed int. */ + RG32I = GL_RG32I, /** - * Three-component RGB, signed non-normalized, each component - * 32bit, 96bit total. - * + * RGB, each component non-normalized signed int. * @requires_gl40 Extension @extension{ARB,texture_buffer_object_rgb32} */ - RGB32Int = GL_RGB32I - }; + RGB32I = GL_RGB32I, - /** @copydoc AbstractTexture::InternalFormat */ - class MAGNUM_EXPORT InternalFormat { - public: - /** @copybrief AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components, AbstractTexture::ComponentType) */ - InternalFormat(Components components, ComponentType type); + /** RGBA, each component non-normalized signed int. */ + RGBA32I = GL_RGBA32I, - /** @copydoc AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Format) */ - inline constexpr InternalFormat(Format format): internalFormat(static_cast(format)) {} + /** Red component, half float. */ + R16F = GL_R16F, - /** - * @brief OpenGL internal format ID - * - * @todoc Remove workaround when Doxygen supports \@copydoc for conversion operators - */ - inline constexpr operator GLint() const { return internalFormat; } + /** Red and green component, each half float. */ + RG16F = GL_RG16F, - private: - GLint internalFormat; - }; + /** RGBA, each component half float. */ + RGBA16F = GL_RGBA16F, - /*@}*/ + /** Red component, float. */ + R32F = GL_R32F, + + /** Red and green component, each float. */ + RG32F = GL_RG32F, + + /** + * RGB, each component float. + * @requires_gl40 Extension @extension{ARB,texture_buffer_object_rgb32} + */ + RGB32F = GL_RGB32F, + + /** RGBA, each component float. */ + RGBA32F = GL_RGBA32F + }; inline BufferedTexture(): AbstractTexture(GL_TEXTURE_BUFFER) {} @@ -178,19 +223,6 @@ class MAGNUM_EXPORT BufferedTexture: private AbstractTexture { static SetBufferImplementation setBufferImplementation; }; -/** @relates BufferedTexture -@brief Convertor of component count and data type to InternalFormat -*/ -inline BufferedTexture::InternalFormat operator|(BufferedTexture::Components components, BufferedTexture::ComponentType type) { - return BufferedTexture::InternalFormat(components, type); -} -/** @relates BufferedTexture - * @overload - */ -inline BufferedTexture::InternalFormat operator|(BufferedTexture::ComponentType type, BufferedTexture::Components components) { - return BufferedTexture::InternalFormat(components, type); -} - } #endif diff --git a/src/Renderbuffer.cpp b/src/Renderbuffer.cpp index bb5be459b..6e3cb17ee 100644 --- a/src/Renderbuffer.cpp +++ b/src/Renderbuffer.cpp @@ -17,61 +17,4 @@ namespace Magnum { -#ifndef MAGNUM_TARGET_GLES2 -Renderbuffer::InternalFormat::InternalFormat(Components components, ComponentType type) { - #ifndef MAGNUM_TARGET_GLES - #define internalFormatSwitch(c) switch(type) { \ - case ComponentType::UnsignedByte: \ - internalFormat = GL_##c##8UI; break; \ - case ComponentType::Byte: \ - internalFormat = GL_##c##8I; break; \ - case ComponentType::UnsignedShort: \ - internalFormat = GL_##c##16UI; break; \ - case ComponentType::Short: \ - internalFormat = GL_##c##16I; break; \ - case ComponentType::UnsignedInt: \ - internalFormat = GL_##c##32UI; break; \ - case ComponentType::Int: \ - internalFormat = GL_##c##32I; break; \ - case ComponentType::Half: \ - internalFormat = GL_##c##16F; break; \ - case ComponentType::Float: \ - internalFormat = GL_##c##32F; break; \ - case ComponentType::NormalizedUnsignedByte: \ - internalFormat = GL_##c##8; break; \ - case ComponentType::NormalizedUnsignedShort: \ - internalFormat = GL_##c##16; break; \ - } - #else - #define internalFormatSwitch(c) switch(type) { \ - case ComponentType::UnsignedByte: \ - internalFormat = GL_##c##8UI; break; \ - case ComponentType::Byte: \ - internalFormat = GL_##c##8I; break; \ - case ComponentType::UnsignedShort: \ - internalFormat = GL_##c##16UI; break; \ - case ComponentType::Short: \ - internalFormat = GL_##c##16I; break; \ - case ComponentType::UnsignedInt: \ - internalFormat = GL_##c##32UI; break; \ - case ComponentType::Int: \ - internalFormat = GL_##c##32I; break; \ - case ComponentType::Half: \ - internalFormat = GL_##c##16F; break; \ - case ComponentType::Float: \ - internalFormat = GL_##c##32F; break; \ - case ComponentType::NormalizedUnsignedByte: \ - internalFormat = GL_##c##8; break; \ - } - #endif - if(components == Components::Red) - internalFormatSwitch(R) - else if(components == Components::RedGreen) - internalFormatSwitch(RG) - else if(components == Components::RGBA) - internalFormatSwitch(RGBA) - #undef internalFormatSwitch -} -#endif - } diff --git a/src/Renderbuffer.h b/src/Renderbuffer.h index 2ee87b8bc..42bd27bac 100644 --- a/src/Renderbuffer.h +++ b/src/Renderbuffer.h @@ -40,156 +40,471 @@ class Renderbuffer { Renderbuffer& operator=(Renderbuffer&& other) = delete; public: - /** @{ @name Internal renderbuffer formats */ - - #ifndef MAGNUM_TARGET_GLES2 /** - * @copybrief AbstractTexture::Components + * @brief Internal format * - * Like AbstractTexture::Components, without three-component RGB. - * @requires_gles30 (no extension providing this functionality) + * @see @ref Texture::setData() "setData()" + * @todo RGB, RGB8 ES only (ES3 + @es_extension{OES,rgb8_rgba8}) */ - enum class Components { - Red, RedGreen, RGBA - }; + enum class InternalFormat: GLenum { + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this + * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::R8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + Red = GL_RED, + #endif - /** - * @copybrief AbstractTexture::ComponentType - * - * Like AbstractTexture::ComponentType, without normalized signed - * types. - * @requires_gles30 (no extension providing this functionality) - */ - enum class ComponentType { - UnsignedByte, Byte, UnsignedShort, Short, UnsignedInt, Int, Half, - Float, NormalizedUnsignedByte + /** + * Red component, normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} + */ + #ifndef MAGNUM_TARGET_GLES2 + R8 = GL_R8, + #else + R8 = GL_R8_EXT, + #endif #ifndef MAGNUM_TARGET_GLES - , NormalizedUnsignedShort + /** + * Red and green component, normalized unsigned, size + * implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this + * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::RG8". + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + RG = GL_RG, #endif - }; - #endif - /** - * @copybrief AbstractTexture::Format - * - * Like AbstractTexture::Format without - * AbstractTexture::Format::RGB9Intensity5, three-component and - * compressed formats, but with added separate stencil index. - */ - enum class Format: GLenum { + /** + * Red and green component, each normalized unsigned byte. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gles30 %Extension @es_extension{EXT,texture_rg} + */ #ifndef MAGNUM_TARGET_GLES2 - Red = GL_RED, RedGreen = GL_RG, + RG8 = GL_RG8, + #else + RG8 = GL_RG8_EXT, #endif + #ifndef MAGNUM_TARGET_GLES + /** + * RGBA, normalized unsigned, size implementation-dependent. + * @deprecated Prefer to use the exactly specified version of this + * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::RGBA8". + * @requires_gl Use exactly specified format in OpenGL ES 2.0 + * instead. + */ RGBA = GL_RGBA, + #endif + + /** + * RGBA, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{ARM,rgba8} or + * @es_extension{OES,required_internalformat} and @es_extension{OES,rgb8_rgba8} + */ + #ifndef MAGNUM_TARGET_GLES2 + RGBA8 = GL_RGBA8, + #else + RGBA8 = GL_RGBA8_OES, + #endif #ifndef MAGNUM_TARGET_GLES - BGRA = GL_BGRA, + /** + * Red component, normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. + */ + R16 = GL_R16, + + /** + * Red and green component, each normalized unsigned short. + * @requires_gl30 %Extension @extension{ARB,texture_rg} + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. + */ + RG16 = GL_RG16, + + /** + * RGB, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. + */ + RGB16 = GL_RGB16, + + /** + * RGBA, each component normalized unsigned short. + * @requires_gl Only byte-sized normalized formats are available + * in OpenGL ES. + */ + RGBA16 = GL_RGBA16, #endif #ifndef MAGNUM_TARGET_GLES2 - SRGBA = GL_SRGB8_ALPHA8, RGB10Alpha2 = GL_RGB10_A2, - RGB10AlphaUnsigned2 = GL_RGB10_A2UI, + /** + * Red component, non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R8UI = GL_R8UI, + + /** + * Red and green component, each non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG8UI = GL_RG8UI, + + /** + * RGBA, each component non-normalized unsigned byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA8UI = GL_RGBA8UI, + + /** + * Red component, non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R8I = GL_R8I, + + /** + * Red and green component, each non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG8I = GL_RG8I, + + /** + * RGBA, each component non-normalized signed byte. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA8I = GL_RGBA8I, + + /** + * Red component, non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R16UI = GL_R16UI, + + /** + * Red and green component, each non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG16UI = GL_RG16UI, + + /** + * RGBA, each component non-normalized unsigned short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA16UI = GL_RGBA16UI, + + /** + * Red component, non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R16I = GL_R16I, + + /** + * Red and green component, each non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG16I = GL_RG16I, + + /** + * RGBA, each component non-normalized signed short. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA16I = GL_RGBA16I, + + /** + * Red component, non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R32UI = GL_R32UI, + + /** + * Red and green component, each non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG32UI = GL_RG32UI, + + /** + * RGBA, each component non-normalized unsigned int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA32UI = GL_RGBA32UI, + + /** + * Red component, non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + R32I = GL_R32I, + + /** + * Red and green component, each non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RG32I = GL_RG32I, + + /** + * RGBA, each component non-normalized signed int. + * @requires_gl30 %Extension @extension{EXT,texture_integer} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGBA32I = GL_RGBA32I, #endif - RGB5Alpha1 = GL_RGB5_A1, - RGBA4 = GL_RGBA4, + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are + * available in OpenGL ES. + */ + R16F = GL_R16F, + + /** + * Red and green component, each half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are + * available in OpenGL ES. + */ + RG16F = GL_RG16F, + + /** + * RGBA, each component half float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are + * available in OpenGL ES. + */ + RGBA16F = GL_RGBA16F, + + /** + * Red component, float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are + * available in OpenGL ES. + */ + R32F = GL_R32F, + + /** + * Red and green component, each float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are + * available in OpenGL ES. + */ + RG32F = GL_RG32F, + + /** + * RGBA, each component float. + * @requires_gl30 %Extension @extension{ARB,texture_float} + * @requires_gl Only (non)normalized integral formats are + * available in OpenGL ES. + */ + RGBA32F = GL_RGBA32F, + #endif #ifndef MAGNUM_TARGET_GLES2 - RFloat11GFloat11BFloat10 = GL_R11F_G11F_B10F, + /** + * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gles30 Usable only as internal texture format in OpenGL + * ES 2.0, see @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::RGB10A2". + */ + RGB10A2 = GL_RGB10_A2, + + /** + * RGBA, non-normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gl33 %Extension @extension{ARB,texture_rgb10_a2ui} + * @requires_gles30 Only normalized integral formats are available + * in OpenGL ES 2.0. + */ + RGB10A2UI = GL_RGB10_A2UI, + #endif + + /** RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. */ + RGB5A1 = GL_RGB5_A1, + + /** RGBA, normalized unsigned, each component 4bit. */ + RGBA4 = GL_RGBA4, + + #ifndef MAGNUM_TARGET_GLES + /** + * RGB, float, red and green 11bit, blue 10bit. + * @requires_gl30 %Extension @extension{EXT,packed_float} + * @requires_gl Usable only as internal texture format in OpenGL + * ES, see @ref Magnum::AbstractTexture::InternalFormat "InternalFormat::R11FG11FB10F". + */ + R11FG11FB10F = GL_R11F_G11F_B10F, #endif /* 1.5.6 <= GLEW < 1.8.0 doesn't have this, even if there is GL_ARB_ES2_compatibility */ #if defined(GL_RGB565) || defined(DOXYGEN_GENERATING_OUTPUT) + /** RGB, normalized unsigned, red and blue 5bit, green 6bit. */ RGB565 = GL_RGB565, #endif - #ifndef MAGNUM_TARGET_GLES /** - * Depth component, at least 16bit. - * - * Prefer to use the exactly specified version of this format, in - * this case e.g. `Format::%Depth16`. - * @requires_gl Use exactly specified format Format::%Depth16 instead. + * sRGBA, each component normalized unsigned byte. + * @requires_gles30 %Extension @es_extension{EXT,sRGB} */ - Depth = GL_DEPTH_COMPONENT, + #ifndef MAGNUM_TARGET_GLES2 + SRGB8Alpha8 = GL_SRGB8_ALPHA8, + #else + SRGB8Alpha8 = GL_SRGB8_ALPHA8_EXT, + #endif - DepthStencil = GL_DEPTH_STENCIL, + #ifndef MAGNUM_TARGET_GLES + /** + * Depth component, size implementation-dependent. + * @todo is this allowed in core? + * @deprecated Prefer to use exactly specified version of this + * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::DepthComponent16". + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + DepthComponent = GL_DEPTH_COMPONENT, #endif - Depth16 = GL_DEPTH_COMPONENT16, + /** Depth component, 16bit. */ + DepthComponent16 = GL_DEPTH_COMPONENT16, + /** + * Depth component, 24bit. + * @requires_gles30 %Extension @es_extension{OES,depth24} + */ + #ifndef MAGNUM_TARGET_GLES2 + DepthComponent24 = GL_DEPTH_COMPONENT24, + #else + DepthComponent24 = GL_DEPTH_COMPONENT24_OES, + #endif + + /** + * Depth component, 32bit. + * @requires_es_extension %Extension @es_extension{OES,depth32} + */ #ifndef MAGNUM_TARGET_GLES - Depth24 = GL_DEPTH_COMPONENT24, - DepthFloat = GL_DEPTH_COMPONENT32F, + DepthComponent32 = GL_DEPTH_COMPONENT32, + #else + DepthComponent32 = GL_DEPTH_COMPONENT32_OES, + #endif + #ifndef MAGNUM_TARGET_GLES2 /** - * Stencil index (unspecified size). - * - * Prefer to use the exactly specified version of this format, in - * this case e.g. `Format::%Stencil8`. - * @requires_gl Use exactly specified format Format::%Stencil8 instead. + * Depth component, 32bit float. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in + * OpenGL ES 2.0. */ - Stencil = GL_STENCIL_INDEX, + DepthComponent32F = GL_DEPTH_COMPONENT32F, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Stencil index, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this + * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::StencilIndex8". + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + StencilIndex = GL_STENCIL_INDEX, + #endif /** * 1-bit stencil index. - * - * @requires_gl Use Format::%Stencil8 instead. + * @requires_es_extension %Extension @es_extension{OES,stencil1} */ - Stencil1 = GL_STENCIL_INDEX1, + #ifndef MAGNUM_TARGET_GLES + StencilIndex1 = GL_STENCIL_INDEX1, + #else + StencilIndex1 = GL_STENCIL_INDEX1_OES, + #endif /** * 4-bit stencil index. - * - * @requires_gl Use Format::%Stencil8 instead. + * @requires_es_extension %Extension @es_extension{OES,stencil4} */ - Stencil4 = GL_STENCIL_INDEX4, + #ifndef MAGNUM_TARGET_GLES + StencilIndex4 = GL_STENCIL_INDEX4, + #else + StencilIndex4 = GL_STENCIL_INDEX4_OES, #endif /** 8-bit stencil index. */ - Stencil8 = GL_STENCIL_INDEX8 + StencilIndex8 = GL_STENCIL_INDEX8, #ifndef MAGNUM_TARGET_GLES - , - /** * 16-bit stencil index. - * - * @requires_gl Use Format::%Stencil8 instead. + * @requires_gl At most 8bit stencil index is available in OpenGL + * ES. */ - Stencil16 = GL_STENCIL_INDEX1, + StencilIndex16 = GL_STENCIL_INDEX16, - Depth24Stencil8 = GL_DEPTH24_STENCIL8, - DepthFloatStencil8 = GL_DEPTH32F_STENCIL8 + /** + * Depth and stencil component, size implementation-dependent. + * @deprecated Prefer to use exactly specified version of this + * format, e.g. @ref Magnum::Renderbuffer::InternalFormat "InternalFormat::Depth24Stencil8". + * @requires_gl Use exactly specified format in OpenGL ES instead. + */ + DepthStencil = GL_DEPTH_STENCIL, #endif - }; - /** @copydoc AbstractTexture::InternalFormat */ - class MAGNUM_EXPORT InternalFormat { - public: - #ifndef MAGNUM_TARGET_GLES2 - /** @copydoc AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Components, AbstractTexture::ComponentType) */ - InternalFormat(Components components, ComponentType type); - #endif - - /** @copydoc AbstractTexture::InternalFormat::InternalFormat(AbstractTexture::Format) */ - inline constexpr InternalFormat(Format format): internalFormat(static_cast(format)) {} - - /** - * @brief OpenGL internal format ID - * - * @todoc Remove workaround when Doxygen supports \@copydoc for conversion operators - */ - inline constexpr operator GLenum() const { return internalFormat; } - - private: - GLenum internalFormat; - }; + /** + * 24bit depth and 8bit stencil component. + * @requires_gl30 %Extension @extension{EXT,packed_depth_stencil} + * @requires_gles30 %Extension @es_extension{OES,packed_depth_stencil} + */ + #ifdef MAGNUM_TARGET_GLES2 + Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES, + #else + Depth24Stencil8 = GL_DEPTH24_STENCIL8, - /*@}*/ + /** + * 32bit float depth component and 8bit stencil component. + * @requires_gl30 %Extension @extension{ARB,depth_buffer_float} + * @requires_gles30 Only integral depth textures are available in + * OpenGL ES 2.0. + */ + Depth32FStencil8 = GL_DEPTH32F_STENCIL8, + #endif + }; /** * @brief Constructor @@ -232,30 +547,13 @@ class Renderbuffer { */ inline void setStorage(InternalFormat internalFormat, const Vector2i& size) { bind(); - glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, size.x(), size.y()); + glRenderbufferStorage(GL_RENDERBUFFER, GLenum(internalFormat), size.x(), size.y()); } private: GLuint renderbuffer; }; -#ifndef MAGNUM_TARGET_GLES2 -/** @relates Renderbuffer -@brief Convertor of component count and data type to InternalFormat - -@requires_gles30 (no extension providing this functionality) -*/ -inline Renderbuffer::InternalFormat operator|(Renderbuffer::Components components, Renderbuffer::ComponentType type) { - return Renderbuffer::InternalFormat(components, type); -} -/** @relates Renderbuffer - * @overload - */ -inline Renderbuffer::InternalFormat operator|(Renderbuffer::ComponentType type, Renderbuffer::Components components) { - return Renderbuffer::InternalFormat(components, type); -} -#endif - } #endif