diff --git a/src/Magnum/AbstractImage.cpp b/src/Magnum/AbstractImage.cpp index c05c3f307..42e89cc01 100644 --- a/src/Magnum/AbstractImage.cpp +++ b/src/Magnum/AbstractImage.cpp @@ -63,16 +63,22 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) { case ColorType::UnsignedShort565Rev: #endif case ColorType::UnsignedShort4444: + #ifndef MAGNUM_TARGET_WEBGL case ColorType::UnsignedShort4444Rev: + #endif case ColorType::UnsignedShort5551: + #ifndef MAGNUM_TARGET_WEBGL case ColorType::UnsignedShort1555Rev: + #endif return 2; #ifndef MAGNUM_TARGET_GLES case ColorType::UnsignedInt8888: case ColorType::UnsignedInt8888Rev: case ColorType::UnsignedInt1010102: #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case ColorType::UnsignedInt2101010Rev: + #endif #ifndef MAGNUM_TARGET_GLES2 case ColorType::UnsignedInt10F11F11FRev: case ColorType::UnsignedInt5999Rev: @@ -86,7 +92,9 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) { } switch(format) { + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case ColorFormat::Red: + #endif #ifndef MAGNUM_TARGET_GLES2 case ColorFormat::RedInteger: #endif @@ -100,9 +108,13 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) { case ColorFormat::Luminance: #endif case ColorFormat::DepthComponent: + #ifndef MAGNUM_TARGET_WEBGL case ColorFormat::StencilIndex: + #endif return 1*size; + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case ColorFormat::RG: + #endif #ifndef MAGNUM_TARGET_GLES2 case ColorFormat::RGInteger: #endif @@ -123,7 +135,9 @@ std::size_t AbstractImage::pixelSize(ColorFormat format, ColorType type) { #ifndef MAGNUM_TARGET_GLES2 case ColorFormat::RGBAInteger: #endif + #ifndef MAGNUM_TARGET_WEBGL case ColorFormat::BGRA: + #endif #ifndef MAGNUM_TARGET_GLES case ColorFormat::BGRAInteger: #endif diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 8af499ac2..1a36d0569 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -463,6 +463,7 @@ void AbstractTexture::bindInternal() { ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) { switch(internalFormat) { + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::Red: case TextureFormat::R8: #ifndef MAGNUM_TARGET_GLES2 @@ -482,6 +483,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedSignedRedRgtc1: #endif return ColorFormat::Red; + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R8UI: @@ -493,6 +495,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in return ColorFormat::RedInteger; #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::RG: case TextureFormat::RG8: #ifndef MAGNUM_TARGET_GLES2 @@ -512,6 +515,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::CompressedSignedRGRgtc2: #endif return ColorFormat::RG; + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RG8UI: @@ -524,7 +528,9 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in #endif case TextureFormat::RGB: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::RGB8: + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGB8Snorm: #endif @@ -542,7 +548,7 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in case TextureFormat::RGB5: #endif case TextureFormat::RGB565: - #ifndef MAGNUM_TARGET_GLES3 + #if !defined(MAGNUM_TARGET_GLES3) && !defined(MAGNUM_TARGET_WEBGL) case TextureFormat::RGB10: #endif #ifndef MAGNUM_TARGET_GLES @@ -574,7 +580,9 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in #endif case TextureFormat::RGBA: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::RGBA8: + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::RGBA8Snorm: #endif @@ -591,7 +599,9 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in #endif case TextureFormat::RGBA4: case TextureFormat::RGB5A1: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::RGB10A2: + #endif #ifndef MAGNUM_TARGET_GLES case TextureFormat::RGBA12: #endif @@ -625,9 +635,13 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in #endif case TextureFormat::DepthComponent: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::DepthComponent16: case TextureFormat::DepthComponent24: + #endif + #ifndef MAGNUM_TARGET_WEBGL case TextureFormat::DepthComponent32: + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::DepthComponent32F: #endif @@ -639,7 +653,9 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in #endif case TextureFormat::DepthStencil: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::Depth24Stencil8: + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::Depth32FStencil8: #endif @@ -651,14 +667,18 @@ ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat in ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat internalFormat) { switch(internalFormat) { + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::Red: case TextureFormat::RG: + #endif case TextureFormat::RGB: case TextureFormat::RGBA: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::R8: case TextureFormat::RG8: case TextureFormat::RGB8: case TextureFormat::RGBA8: + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R8UI: case TextureFormat::RG8UI: @@ -785,6 +805,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::RGB565: return ColorType::UnsignedShort565; + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #ifndef MAGNUM_TARGET_GLES3 case TextureFormat::RGB10: #endif @@ -793,6 +814,7 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern case TextureFormat::RGB10A2UI: #endif return ColorType::UnsignedInt2101010Rev; /**< @todo Rev for all? */ + #endif #ifndef MAGNUM_TARGET_GLES2 case TextureFormat::R11FG11FB10F: @@ -801,12 +823,18 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern return ColorType::UnsignedInt5999Rev; #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::DepthComponent16: return ColorType::UnsignedShort; + #endif case TextureFormat::DepthComponent: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::DepthComponent24: + #endif + #ifndef MAGNUM_TARGET_WEBGL case TextureFormat::DepthComponent32: + #endif return ColorType::UnsignedInt; #ifndef MAGNUM_TARGET_GLES2 @@ -820,7 +848,9 @@ ColorType AbstractTexture::imageTypeForInternalFormat(const TextureFormat intern #endif case TextureFormat::DepthStencil: + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::Depth24Stencil8: + #endif return ColorType::UnsignedInt248; #ifndef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/ColorFormat.cpp b/src/Magnum/ColorFormat.cpp index eb6bec697..0c7a70b7b 100644 --- a/src/Magnum/ColorFormat.cpp +++ b/src/Magnum/ColorFormat.cpp @@ -33,7 +33,9 @@ namespace Magnum { Debug operator<<(Debug debug, const ColorFormat value) { switch(value) { #define _c(value) case ColorFormat::value: return debug << "ColorFormat::" #value; + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) _c(Red) + #endif #ifndef MAGNUM_TARGET_GLES _c(Green) _c(Blue) @@ -41,7 +43,9 @@ Debug operator<<(Debug debug, const ColorFormat value) { #ifdef MAGNUM_TARGET_GLES2 _c(Luminance) #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) _c(RG) + #endif #ifdef MAGNUM_TARGET_GLES2 _c(LuminanceAlpha) #endif @@ -50,7 +54,9 @@ Debug operator<<(Debug debug, const ColorFormat value) { #ifndef MAGNUM_TARGET_GLES _c(BGR) #endif + #ifndef MAGNUM_TARGET_WEBGL _c(BGRA) + #endif #ifndef MAGNUM_TARGET_GLES2 _c(RedInteger) #ifndef MAGNUM_TARGET_GLES @@ -66,7 +72,9 @@ Debug operator<<(Debug debug, const ColorFormat value) { #endif #endif _c(DepthComponent) + #ifndef MAGNUM_TARGET_WEBGL _c(StencilIndex) + #endif _c(DepthStencil) #undef _c } @@ -100,15 +108,21 @@ Debug operator<<(Debug debug, const ColorType value) { _c(UnsignedShort565Rev) #endif _c(UnsignedShort4444) + #ifndef MAGNUM_TARGET_WEBGL _c(UnsignedShort4444Rev) + #endif _c(UnsignedShort5551) + #ifndef MAGNUM_TARGET_WEBGL _c(UnsignedShort1555Rev) + #endif #ifndef MAGNUM_TARGET_GLES _c(UnsignedInt8888) _c(UnsignedInt8888Rev) _c(UnsignedInt1010102) #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) _c(UnsignedInt2101010Rev) + #endif #ifndef MAGNUM_TARGET_GLES2 _c(UnsignedInt10F11F11FRev) _c(UnsignedInt5999Rev) diff --git a/src/Magnum/ColorFormat.h b/src/Magnum/ColorFormat.h index 3185491a0..d91aeafea 100644 --- a/src/Magnum/ColorFormat.h +++ b/src/Magnum/ColorFormat.h @@ -53,28 +53,35 @@ See documentation of these values for possible limitations when using OpenGL ES @see @ref Image, @ref ImageReference, @ref BufferImage, @ref Trade::ImageData */ enum class ColorFormat: GLenum { + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Floating-point red channel. - * @requires_gles30 For texture data only, extension @es_extension{EXT,texture_rg} - * in OpenGL ES 2.0 - * @requires_es_extension For framebuffer reading, extension @es_extension{EXT,texture_rg} + * @requires_gles30 For texture data only, extension + * @es_extension{EXT,texture_rg} in OpenGL ES 2.0. + * @requires_es_extension For framebuffer reading, extension + * @es_extension{EXT,texture_rg} + * @requires_webgl20 For texture data only. Not available in WebGL 1.0, see + * @ref ColorFormat::Luminance for an alternative. */ #ifndef MAGNUM_TARGET_GLES2 Red = GL_RED, #else Red = GL_RED_EXT, #endif + #endif #ifndef MAGNUM_TARGET_GLES /** * Floating-point green channel. - * @requires_gl Only @ref ColorFormat::Red is available in OpenGL ES. + * @requires_gl Only @ref ColorFormat::Red is available in OpenGL ES or + * WebGL. */ Green = GL_GREEN, /** * Floating-point blue channel. - * @requires_gl Only @ref ColorFormat::Red is available in OpenGL ES. + * @requires_gl Only @ref ColorFormat::Red is available in OpenGL ES or + * WebGL. */ Blue = GL_BLUE, #endif @@ -83,33 +90,38 @@ enum class ColorFormat: GLenum { /** * Floating-point luminance channel. The value is used for all RGB * channels. - * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use - * @ref ColorFormat::Red instead. + * @requires_gles20 Not available in ES 3.0, WebGL 2.0 or desktop OpenGL. + * Use @ref ColorFormat::Red instead. * @deprecated_gl Included for compatibility reasons only, use * @ref ColorFormat::Red instead. */ Luminance = GL_LUMINANCE, #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Floating-point red and green channel. * @requires_gl30 Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} - * @requires_gles30 For texture data only, extension @es_extension{EXT,texture_rg} - * in OpenGL ES 2.0 - * @requires_es_extension For framebuffer reading, extension @es_extension{EXT,texture_rg}. + * @requires_gles30 For texture data only, extension + * @es_extension{EXT,texture_rg} in OpenGL ES 2.0. + * @requires_es_extension For framebuffer reading, extension + * @es_extension{EXT,texture_rg} + * @requires_webgl20 For texture data only. Not available in WebGL 1.0, see + * @ref ColorFormat::LuminanceAlpha for and alternative. */ #ifndef MAGNUM_TARGET_GLES2 RG = GL_RG, #else RG = GL_RG_EXT, #endif + #endif #if defined(MAGNUM_TARGET_GLES2) || defined(DOXYGEN_GENERATING_OUTPUT) /** * Floating-point luminance and alpha channel. First value is used for all * RGB channels, second value is used for alpha channel. - * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use - * @ref ColorFormat::RG instead. + * @requires_gles20 Not available in ES 3.0, WebGL 2.0 or desktop OpenGL. + * Use @ref ColorFormat::RG instead. * @deprecated_gl Included for compatibility reasons only, use * @ref ColorFormat::RG instead. */ @@ -118,7 +130,7 @@ enum class ColorFormat: GLenum { /** * Floating-point RGB. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or WebGL. */ RGB = GL_RGB, @@ -128,22 +140,26 @@ enum class ColorFormat: GLenum { #ifndef MAGNUM_TARGET_GLES /** * Floating-point BGR. - * @requires_gl Only RGB component ordering is available in OpenGL ES. + * @requires_gl Only RGB component ordering is available in OpenGL ES and + * WebGL. */ BGR = GL_BGR, #endif + #ifndef MAGNUM_TARGET_WEBGL /** * Floating-point BGRA. * @requires_es_extension Extension @es_extension{EXT,read_format_bgra} * for framebuffer reading, extension @es_extension{APPLE,texture_format_BGRA8888} * or @es_extension{EXT,texture_format_BGRA8888} for texture data. + * @requires_gles Only RGBA component ordering is available in WebGL. */ #ifndef MAGNUM_TARGET_GLES BGRA = GL_BGRA, #else BGRA = GL_BGRA_EXT, #endif + #endif #ifndef MAGNUM_TARGET_GLES2 /** @@ -151,6 +167,8 @@ enum class ColorFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only floating-point image data are available in OpenGL * ES 2.0. + * @requires_webgl20 Only floating-point image data are available in WebGL + * 1.0. */ RedInteger = GL_RED_INTEGER, @@ -159,7 +177,8 @@ enum class ColorFormat: GLenum { * Integer green channel. * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gl Only @ref ColorFormat::RedInteger is available in OpenGL ES - * 3.0, only floating-point image data are available in OpenGL ES 2.0. + * 3.0 and WebGL 2.0, only floating-point image data are available in + * OpenGL ES 2.0 and WebGL 1.0. */ GreenInteger = GL_GREEN_INTEGER, @@ -167,7 +186,8 @@ enum class ColorFormat: GLenum { * Integer blue channel. * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gl Only @ref ColorFormat::RedInteger is available in OpenGL ES - * 3.0, only floating-point image data are available in OpenGL ES 2.0. + * 3.0 and WebGL 2.0, only floating-point image data are available in + * OpenGL ES 2.0 and WebGL 1.0. */ BlueInteger = GL_BLUE_INTEGER, #endif @@ -175,18 +195,24 @@ enum class ColorFormat: GLenum { /** * Integer red and green channel. * @requires_gl30 Extension @extension{ARB,texture_rg} and @extension{EXT,texture_integer} - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or + * WebGL. * @requires_gles30 For texture data only, only floating-point image data * are available in OpenGL ES 2.0. + * @requires_webgl20 For texture data only, only floating-point image data + * are available in WebGL 1.0. */ RGInteger = GL_RG_INTEGER, /** * Integer RGB. * @requires_gl30 Extension @extension{EXT,texture_integer} - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or + * WebGL. * @requires_gles30 For texture data only, only floating-point image data * are available in OpenGL ES 2.0. + * @requires_webgl20 For texture data only, only floating-point image data + * are available in WebGL 1.0. */ RGBInteger = GL_RGB_INTEGER, @@ -195,6 +221,8 @@ enum class ColorFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only floating-point image data are available in OpenGL * ES 2.0. + * @requires_webgl20 Only floating-point image data are available in WebGL + * 1.0. */ RGBAInteger = GL_RGBA_INTEGER, @@ -203,7 +231,8 @@ enum class ColorFormat: GLenum { * Integer BGR. * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gl Only @ref ColorFormat::RGBInteger is available in OpenGL ES - * 3.0, only floating-point image data are available in OpenGL ES 2.0. + * 3.0 and WebGL 2.0, only floating-point image data are available in + * OpenGL ES 2.0 and WebGL 1.0. */ BGRInteger = GL_BGR_INTEGER, @@ -211,8 +240,8 @@ enum class ColorFormat: GLenum { * Integer BGRA. * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gl Only @ref ColorFormat::RGBAInteger is available in OpenGL - * ES 3.0, only floating-point image data are available in OpenGL ES - * 2.0. + * ES 3.0 and WebGL 2.0, only floating-point image data are available + * in OpenGL ES 2.0 and WebGL 1.0. */ BGRAInteger = GL_BGRA_INTEGER, #endif @@ -221,18 +250,22 @@ enum class ColorFormat: GLenum { /** * Depth component. * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} - * or @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0 + * or @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0. * @requires_es_extension For framebuffer reading only, extension * @es_extension2{NV,read_depth,GL_NV_read_depth_stencil}. + * @requires_webgl20 For texture data only, extension + * @webgl_extension{WEBGL,depth_texture} in WebGL 1.0. */ DepthComponent = GL_DEPTH_COMPONENT, + #ifndef MAGNUM_TARGET_WEBGL /** * Stencil index. * @requires_gl44 Extension @extension{ARB,texture_stencil8} for texture * data, otherwise for framebuffer reading only. * @requires_es_extension Extension @es_extension2{NV,read_stencil,GL_NV_read_depth_stencil}, * for framebuffer reading only. + * @requires_gles Stencil index is not available in WebGL. * @todo Where to get GL_STENCIL_INDEX in ES? */ #ifndef MAGNUM_TARGET_GLES @@ -240,18 +273,23 @@ enum class ColorFormat: GLenum { #else StencilIndex = 0x1901, #endif + #endif /** * Depth and stencil. * @requires_gl30 Extension @extension{ARB,framebuffer_object} * @requires_gles30 For texture data only, extension @es_extension{OES,packed_depth_stencil} - * in OpenGL ES 2.0 + * in OpenGL ES 2.0. * @requires_es_extension For framebuffer reading only, extension * @es_extension2{NV,read_depth_stencil,GL_NV_read_depth_stencil} + * @requires_webgl20 For texture data only, extension + * @webgl_extension{WEBGL,depth_texture} in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 DepthStencil = GL_DEPTH_STENCIL #else + /* Using OES version even though WebGL 1.0 *has* DEPTH_STENCIL constant, + because there are no such headers for it */ DepthStencil = GL_DEPTH_STENCIL_OES #endif }; @@ -280,36 +318,46 @@ enum class ColorType: GLenum { #ifndef MAGNUM_TARGET_GLES2 /** * Each component signed byte. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. * @requires_gles30 For texture data only, only @ref ColorType::UnsignedByte * is available in OpenGL ES 2.0. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or + * WebGL. + * @requires_webgl20 For texture data only, only @ref ColorType::UnsignedByte + * is available in WebGL 1.0. */ Byte = GL_BYTE, #endif /** * Each component unsigned short. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} - * or @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0 + * or @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or + * WebGL. + * @requires_webgl20 For texture data only, extension + * @webgl_extension{WEBGL,depth_texture} in WebGL 1.0. */ UnsignedShort = GL_UNSIGNED_SHORT, #ifndef MAGNUM_TARGET_GLES2 /** * Each component signed short. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or + * WebGL. * @requires_gles30 For texture data only, only @ref ColorType::UnsignedShort * is available in OpenGL ES 2.0. + * @requires_webgl20 For texture data only, only @ref ColorType::UnsignedShort + * is available in WebGL 1.0. */ Short = GL_SHORT, #endif /** * Each component unsigned int. - * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} - * or @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0 + * or @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0. + * @requires_webgl20 For texture data only, extension + * @webgl_extension{WEBGL,depth_texture} in WebGL 1.0. */ UnsignedInt = GL_UNSIGNED_INT, @@ -318,6 +366,8 @@ enum class ColorType: GLenum { * Each component signed int. * @requires_gles30 Only @ref ColorType::UnsignedInt is available in OpenGL * ES 2.0. + * @requires_webgl20 Only @ref ColorType::UnsignedInt is available in WebGL + * 1.0. */ Int = GL_INT, #endif @@ -327,7 +377,9 @@ enum class ColorType: GLenum { * @requires_gl30 Extension @extension{ARB,half_float_pixel} * @requires_gles30 For texture data only, extension * @es_extension2{OES,texture_half_float,OES_texture_float} in OpenGL - * ES 2.0 + * ES 2.0. + * @requires_webgl20 For texture data only, extension + * @webgl_extension{OES,texture_half_float} in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 HalfFloat = GL_HALF_FLOAT, @@ -338,27 +390,29 @@ enum class ColorType: GLenum { /** * Each component float. * @requires_gles30 For texture data only, extension @es_extension{OES,texture_float} - * in OpenGL ES 2.0 + * in OpenGL ES 2.0. + * @requires_webgl20 For texture data only, extension @webgl_extension{OES,texture_float} + * in WebGL 1.0. */ Float = GL_FLOAT, #ifndef MAGNUM_TARGET_GLES /** * RGB, unsigned byte, red and green component 3bit, blue component 2bit. - * @requires_gl Packed 12bit types are not available in OpenGL ES. + * @requires_gl Packed 12bit types are not available in OpenGL ES or WebGL. */ UnsignedByte332 = GL_UNSIGNED_BYTE_3_3_2, /** * BGR, unsigned byte, red and green component 3bit, blue component 2bit. - * @requires_gl Packed 12bit types are not available in OpenGL ES. + * @requires_gl Packed 12bit types are not available in OpenGL ES or WebGL. */ UnsignedByte233Rev = GL_UNSIGNED_BYTE_2_3_3_REV, #endif /** * RGB, unsigned byte, red and blue component 5bit, green 6bit. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or WebGL. */ UnsignedShort565 = GL_UNSIGNED_SHORT_5_6_5, @@ -366,78 +420,90 @@ enum class ColorType: GLenum { /** * BGR, unsigned short, red and blue 5bit, green 6bit. * @requires_gl Only @ref ColorType::UnsignedShort565 is available in - * OpenGL ES. + * OpenGL ES or WebGL. */ UnsignedShort565Rev = GL_UNSIGNED_SHORT_5_6_5_REV, #endif /** * RGBA, unsigned short, each component 4bit. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or WebGL. */ UnsignedShort4444 = GL_UNSIGNED_SHORT_4_4_4_4, + #ifndef MAGNUM_TARGET_WEBGL /** * ABGR, unsigned short, each component 4bit. * @requires_es_extension For framebuffer reading only, extension - * @es_extension{EXT,read_format_bgra}. + * @es_extension{EXT,read_format_bgra} + * @requires_gles Only RGBA component ordering is available in WebGL. */ #ifndef MAGNUM_TARGET_GLES UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV, #else UnsignedShort4444Rev = GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, #endif + #endif /** * RGBA, unsigned short, each RGB component 5bit, alpha component 1bit. - * @requires_gl Can't be used for framebuffer reading in OpenGL ES. + * @requires_gl Can't be used for framebuffer reading in OpenGL ES or WebGL. */ UnsignedShort5551 = GL_UNSIGNED_SHORT_5_5_5_1, + #ifndef MAGNUM_TARGET_WEBGL /** * ABGR, unsigned short, each RGB component 5bit, alpha component 1bit. * @requires_es_extension For framebuffer reading only, extension - * @es_extension{EXT,read_format_bgra}. + * @es_extension{EXT,read_format_bgra} + * @requires_gles Not available in WebGL. */ #ifndef MAGNUM_TARGET_GLES UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV, #else UnsignedShort1555Rev = GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, #endif + #endif #ifndef MAGNUM_TARGET_GLES /** * RGBA, unsigned int, each component 8bit. - * @requires_gl Use @ref ColorType::UnsignedByte in OpenGL ES instead. + * @requires_gl Use @ref ColorType::UnsignedByte in OpenGL ES and WebGL + * instead. */ UnsignedInt8888 = GL_UNSIGNED_INT_8_8_8_8, /** * ABGR, unsigned int, each component 8bit. - * @requires_gl Only RGBA component ordering is available in OpenGL ES, see - * @ref ColorType::UnsignedInt8888 for more information. + * @requires_gl Only RGBA component ordering is available in OpenGL ES and + * WebGL, see @ref ColorType::UnsignedInt8888 for more information. */ UnsignedInt8888Rev = GL_UNSIGNED_INT_8_8_8_8_REV, /** * RGBA, unsigned int, each RGB component 10bit, alpha component 2bit. * @requires_gl Only @ref ColorType::UnsignedInt2101010Rev is available in - * OpenGL ES. + * OpenGL ES and WebGL. */ UnsignedInt1010102 = GL_UNSIGNED_INT_10_10_10_2, #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * ABGR, unsigned int, each RGB component 10bit, alpha component 2bit. * @requires_gles30 Can't be used for framebuffer reading in OpenGL ES 2.0. * @requires_gles30 For texture data only, extension - * @es_extension{EXT,texture_type_2_10_10_10_REV} in OpenGL ES 2.0 + * @es_extension{EXT,texture_type_2_10_10_10_REV} in OpenGL ES 2.0. + * Not available in WebGL 1.0. + * @requires_webgl20 Only RGBA component ordering is available in WebGL + * 1.0. */ #ifndef MAGNUM_TARGET_GLES2 UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV, #else UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV_EXT, #endif + #endif #ifndef MAGNUM_TARGET_GLES2 /** @@ -445,6 +511,7 @@ enum class ColorType: GLenum { * @requires_gl30 Extension @extension{EXT,packed_float} * @requires_gles30 Floating-point types are not available in OpenGL ES * 2.0. + * @requires_webgl20 Floating-point types are not available in WebGL 1.0. */ UnsignedInt10F11F11FRev = GL_UNSIGNED_INT_10F_11F_11F_REV, @@ -453,6 +520,7 @@ enum class ColorType: GLenum { * @requires_gl30 Extension @extension{EXT,texture_shared_exponent} * @requires_gles30 Only 8bit and 16bit types are available in OpenGL ES * 2.0. + * @requires_webgl20 Only 8bit and 16bit types are available in WebGL 1.0. */ UnsignedInt5999Rev = GL_UNSIGNED_INT_5_9_9_9_REV, #endif @@ -460,8 +528,10 @@ enum class ColorType: GLenum { /** * Unsigned int, depth component 24bit, stencil index 8bit. * @requires_gl30 Extension @extension{ARB,framebuffer_object} - * @requires_gles30 For texture data only, extension @es_extension{OES,packed_depth_stencil} - * in OpenGL ES 2.0 + * @requires_gles30 For texture data only, extension + * @es_extension{OES,packed_depth_stencil} in OpenGL ES 2.0. + * @requires_webgl20 For texture data only, extension + * @webgl_extension{WEBGL,depth_texture} in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 UnsignedInt248 = GL_UNSIGNED_INT_24_8, @@ -476,6 +546,8 @@ enum class ColorType: GLenum { * @requires_gl30 Extension @extension{ARB,depth_buffer_float} * @requires_gles30 For texture data only, only @ref ColorType::UnsignedInt248 * is available in OpenGL ES 2.0. + * @requires_webgl20 For texture data only, only @ref ColorType::UnsignedInt248 + * is available in WebGL 1.0. */ Float32UnsignedInt248Rev = GL_FLOAT_32_UNSIGNED_INT_24_8_REV #endif diff --git a/src/Magnum/RenderbufferFormat.h b/src/Magnum/RenderbufferFormat.h index b47bb57aa..723c6a5b9 100644 --- a/src/Magnum/RenderbufferFormat.h +++ b/src/Magnum/RenderbufferFormat.h @@ -45,76 +45,85 @@ enum class RenderbufferFormat: GLenum { /** * Red component, normalized unsigned, size implementation-dependent. * @requires_gl30 Extension @extension{ARB,texture_rg} - * @requires_gl Use exactly specified format in OpenGL ES instead. + * @requires_gl Use exactly specified format in OpenGL ES or WebGL instead. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref RenderbufferFormat::R8. */ Red = GL_RED, #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Red component, normalized unsigned byte. * @requires_gl30 Extension @extension{ARB,texture_rg} * @requires_gles30 Extension @es_extension{EXT,texture_rg} in OpenGL ES - * 2.0 + * 2.0. + * @requires_webgl20 Not available in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 R8 = GL_R8, #else R8 = GL_R8_EXT, #endif + #endif #ifndef MAGNUM_TARGET_GLES /** * Red and green component, normalized unsigned, size * implementation-dependent. * @requires_gl30 Extension @extension{ARB,texture_rg} - * @requires_gl Use exactly specified format in OpenGL ES instead. + * @requires_gl Use exactly specified format in OpenGL ES or WebGL instead. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref RenderbufferFormat::RG8. */ RG = GL_RG, #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Red and green component, each normalized unsigned byte. * @requires_gl30 Extension @extension{ARB,texture_rg} * @requires_gles30 Extension @es_extension{EXT,texture_rg} in OpenGL ES - * 2.0 + * 2.0. + * @requires_webgl20 Not available in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 RG8 = GL_RG8, #else RG8 = GL_RG8_EXT, #endif + #endif #ifndef MAGNUM_TARGET_GLES /** * RGBA, normalized unsigned, size implementation-dependent. - * @requires_gl Use exactly specified format in OpenGL ES 2.0 instead. + * @requires_gl Use exactly specified format in OpenGL ES or WebGL instead. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref RenderbufferFormat::RGBA8. */ RGBA = GL_RGBA, #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * RGBA, each component normalized unsigned byte. * @requires_gles30 Extension @es_extension{ARM,rgba8} or @es_extension{OES,rgb8_rgba8} - * in OpenGL ES 2.0 + * in OpenGL ES 2.0. + * @requires_webgl20 Not available in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 RGBA8 = GL_RGBA8, #else RGBA8 = GL_RGBA8_OES, #endif + #endif #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. + * ES and WebGL. */ R16 = GL_R16, @@ -122,21 +131,21 @@ enum class RenderbufferFormat: GLenum { * 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. + * ES and WebGL. */ RG16 = GL_RG16, /** * RGB, each component normalized unsigned short. * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ RGB16 = GL_RGB16, /** * RGBA, each component normalized unsigned short. * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ RGBA16 = GL_RGBA16, #endif @@ -147,6 +156,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R8UI = GL_R8UI, @@ -155,6 +166,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG8UI = GL_RG8UI, @@ -163,6 +176,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA8UI = GL_RGBA8UI, @@ -171,6 +186,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R8I = GL_R8I, @@ -179,6 +196,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG8I = GL_RG8I, @@ -187,6 +206,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA8I = GL_RGBA8I, @@ -195,6 +216,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R16UI = GL_R16UI, @@ -203,6 +226,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG16UI = GL_RG16UI, @@ -211,6 +236,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA16UI = GL_RGBA16UI, @@ -219,6 +246,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R16I = GL_R16I, @@ -227,6 +256,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG16I = GL_RG16I, @@ -235,6 +266,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA16I = GL_RGBA16I, @@ -243,6 +276,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R32UI = GL_R32UI, @@ -251,6 +286,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG32UI = GL_RG32UI, @@ -259,6 +296,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA32UI = GL_RGBA32UI, @@ -267,6 +306,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R32I = GL_R32I, @@ -275,6 +316,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG32I = GL_RG32I, @@ -283,6 +326,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA32I = GL_RGBA32I, #endif @@ -292,7 +337,7 @@ enum class RenderbufferFormat: GLenum { * Red component, half float. * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gl Only (non)normalized integral formats are available in - * OpenGL ES. + * OpenGL ES and WebGL. */ R16F = GL_R16F, @@ -300,7 +345,7 @@ enum class RenderbufferFormat: GLenum { * 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. + * OpenGL ES and WebGL. */ RG16F = GL_RG16F, @@ -308,7 +353,7 @@ enum class RenderbufferFormat: GLenum { * RGBA, each component half float. * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gl Only (non)normalized integral formats are available in - * OpenGL ES. + * OpenGL ES and WebGL. */ RGBA16F = GL_RGBA16F, @@ -316,7 +361,7 @@ enum class RenderbufferFormat: GLenum { * Red component, float. * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gl Only (non)normalized integral formats are available in - * OpenGL ES. + * OpenGL ES and WebGL. */ R32F = GL_R32F, @@ -324,7 +369,7 @@ enum class RenderbufferFormat: GLenum { * 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. + * OpenGL ES and WebGL. */ RG32F = GL_RG32F, @@ -332,7 +377,7 @@ enum class RenderbufferFormat: GLenum { * RGBA, each component float. * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gl Only (non)normalized integral formats are available in - * OpenGL ES. + * OpenGL ES and WebGL. */ RGBA32F = GL_RGBA32F, #endif @@ -342,6 +387,7 @@ enum class RenderbufferFormat: GLenum { * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. * @requires_gles30 Usable only as internal texture format in OpenGL ES * 2.0, see @ref TextureFormat::RGB10A2. + * @requires_webgl20 Not available in WebGL 1.0. */ RGB10A2 = GL_RGB10_A2, @@ -350,6 +396,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl33 Extension @extension{ARB,texture_rgb10_a2ui} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB10A2UI = GL_RGB10_A2UI, #endif @@ -364,8 +412,8 @@ enum class RenderbufferFormat: GLenum { /** * 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 TextureFormat::R11FG11FB10F. + * @requires_gl Usable only as internal texture format in OpenGL ES and + * WebGL, see @ref TextureFormat::R11FG11FB10F. */ R11FG11FB10F = GL_R11F_G11F_B10F, #endif @@ -375,7 +423,8 @@ enum class RenderbufferFormat: GLenum { /** * sRGBA, each component normalized unsigned byte. - * @requires_gles30 Extension @es_extension{EXT,sRGB} in OpenGL ES 2.0 + * @requires_gles30 Extension @es_extension{EXT,sRGB} in OpenGL ES 2.0. + * @requires_webgl20 Extension @webgl_extension{EXT,sRGB} in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 SRGB8Alpha8 = GL_SRGB8_ALPHA8, @@ -387,7 +436,8 @@ enum class RenderbufferFormat: GLenum { /** * Depth component, size implementation-dependent. * @todo is this allowed in core? - * @requires_gl Use exactly specified format in OpenGL ES instead. + * @requires_gl Use exactly specified format in OpenGL ES and WebGL + * instead. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref RenderbufferFormat::DepthComponent16. */ @@ -397,25 +447,31 @@ enum class RenderbufferFormat: GLenum { /** Depth component, 16bit. */ DepthComponent16 = GL_DEPTH_COMPONENT16, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Depth component, 24bit. - * @requires_gles30 Extension @es_extension{OES,depth24} in OpenGL ES 2.0 + * @requires_gles30 Extension @es_extension{OES,depth24} in OpenGL ES 2.0. + * @requires_webgl20 Only 16bit depth component is available in WebGL. */ #ifndef MAGNUM_TARGET_GLES2 DepthComponent24 = GL_DEPTH_COMPONENT24, #else DepthComponent24 = GL_DEPTH_COMPONENT24_OES, #endif + #endif + #ifndef MAGNUM_TARGET_WEBGL /** * Depth component, 32bit. * @requires_es_extension Extension @es_extension{OES,depth32} + * @requires_gles At most 24bit depth component is available in WebGL. */ #ifndef MAGNUM_TARGET_GLES DepthComponent32 = GL_DEPTH_COMPONENT32, #else DepthComponent32 = GL_DEPTH_COMPONENT32_OES, #endif + #endif #ifndef MAGNUM_TARGET_GLES2 /** @@ -423,6 +479,8 @@ enum class RenderbufferFormat: GLenum { * @requires_gl30 Extension @extension{ARB,depth_buffer_float} * @requires_gles30 Only integral depth textures are available in OpenGL ES * 2.0. + * @requires_webgl20 Only integral depth textures are available in WebGL + * 1.0. */ DepthComponent32F = GL_DEPTH_COMPONENT32F, #endif @@ -430,16 +488,19 @@ enum class RenderbufferFormat: GLenum { #ifndef MAGNUM_TARGET_GLES /** * Stencil index, size implementation-dependent. - * @requires_gl Use exactly specified format in OpenGL ES instead. + * @requires_gl Use exactly specified format in OpenGL ES and WebGL + * instead. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref RenderbufferFormat::StencilIndex8. */ StencilIndex = GL_STENCIL_INDEX, #endif + #ifndef MAGNUM_TARGET_WEBGL /** * 1-bit stencil index. * @requires_es_extension Extension @es_extension{OES,stencil1} + * @requires_gles Only 8bit stencil index is available in WebGL. */ #ifndef MAGNUM_TARGET_GLES StencilIndex1 = GL_STENCIL_INDEX1, @@ -450,12 +511,14 @@ enum class RenderbufferFormat: GLenum { /** * 4-bit stencil index. * @requires_es_extension Extension @es_extension{OES,stencil4} + * @requires_gles Only 8bit stencil index is available in WebGL. */ #ifndef MAGNUM_TARGET_GLES StencilIndex4 = GL_STENCIL_INDEX4, #else StencilIndex4 = GL_STENCIL_INDEX4_OES, #endif + #endif /** 8-bit stencil index. */ StencilIndex8 = GL_STENCIL_INDEX8, @@ -463,34 +526,50 @@ enum class RenderbufferFormat: GLenum { #ifndef MAGNUM_TARGET_GLES /** * 16-bit stencil index. - * @requires_gl At most 8bit stencil index is available in OpenGL ES. + * @requires_gl At most 8bit stencil index is available in OpenGL ES and + * WebGL. */ StencilIndex16 = GL_STENCIL_INDEX16, + #endif + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_WEBGL) /** * Depth and stencil component, size implementation-dependent. - * @requires_gl Use exactly specified format in OpenGL ES instead. + * @requires_gl Use exactly specified format in OpenGL ES instead. This is, + * however, available in WebGL 1.0. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref RenderbufferFormat::Depth24Stencil8. */ + #ifndef MAGNUM_TARGET_GLES DepthStencil = GL_DEPTH_STENCIL, + #else + DepthStencil = GL_DEPTH_STENCIL_OES, + #endif #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * 24bit depth and 8bit stencil component. * @requires_gles30 Extension @es_extension{OES,packed_depth_stencil} in - * OpenGL ES 2.0 + * OpenGL ES 2.0. + * @requires_webgl20 Use @ref RenderbufferFormat::DepthStencil in WebGL + * 1.0 instead. */ #ifdef MAGNUM_TARGET_GLES2 Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES #else Depth24Stencil8 = GL_DEPTH24_STENCIL8, + #endif + #endif + #ifndef MAGNUM_TARGET_GLES2 /** * 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. + * @requires_webgl20 Only integral depth textures are available in WebGL + * 1.0. */ Depth32FStencil8 = GL_DEPTH32F_STENCIL8 #endif diff --git a/src/Magnum/Text/DistanceFieldGlyphCache.cpp b/src/Magnum/Text/DistanceFieldGlyphCache.cpp index 76fc6c9a9..896225b76 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCache.cpp +++ b/src/Magnum/Text/DistanceFieldGlyphCache.cpp @@ -39,10 +39,12 @@ namespace Magnum { namespace Text { DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, const Vector2i& size, const UnsignedInt radius): #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES3) GlyphCache(TextureFormat::R8, originalSize, size, Vector2i(radius)), - #else + #elif !defined(MAGNUM_TARGET_WEBGL) /* Luminance is not renderable in most cases */ GlyphCache(Context::current()->isExtensionSupported() ? TextureFormat::Red : TextureFormat::RGB, originalSize, size, Vector2i(radius)), + #else + GlyphCache(TextureFormat::RGB, originalSize, size, Vector2i(radius)), #endif scale(Vector2(size)/Vector2(originalSize)), radius(radius) { @@ -50,7 +52,7 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::texture_rg); #endif - #ifdef MAGNUM_TARGET_GLES2 + #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /* Luminance is not renderable in most cases */ if(!Context::current()->isExtensionSupported()) Warning() << "Text::DistanceFieldGlyphCache:" << Extensions::GL::EXT::texture_rg::string() << "not supported, using inefficient RGB format for glyph cache texture"; @@ -64,11 +66,14 @@ void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageRefere "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); #else TextureFormat internalFormat; + #ifndef MAGNUM_TARGET_WEBGL if(Context::current()->isExtensionSupported()) { internalFormat = TextureFormat::Red; CORRADE_ASSERT(image.format() == ColorFormat::Red, "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); - } else { + } else + #endif + { internalFormat = TextureFormat::Luminance; CORRADE_ASSERT(image.format() == ColorFormat::Luminance, "Text::DistanceFieldGlyphCache::setImage(): expected" << ColorFormat::Luminance << "but got" << image.format(), ); @@ -90,13 +95,17 @@ void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, cons CORRADE_ASSERT(image.format() == ColorFormat::Red, "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); #else + #ifndef MAGNUM_TARGET_WEBGL if(Context::current()->isExtensionSupported()) CORRADE_ASSERT(image.format() == ColorFormat::Red, "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::Red << "but got" << image.format(), ); - - /* Luminance is not renderable in most cases */ - else CORRADE_ASSERT(image.format() == ColorFormat::RGB, + else + #endif + { + /* Luminance is not renderable in most cases */ + CORRADE_ASSERT(image.format() == ColorFormat::RGB, "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << ColorFormat::RGB << "but got" << image.format(), ); + } #endif texture().setSubImage(0, offset, image); diff --git a/src/Magnum/Text/GlyphCache.cpp b/src/Magnum/Text/GlyphCache.cpp index f9f927251..9c9788baa 100644 --- a/src/Magnum/Text/GlyphCache.cpp +++ b/src/Magnum/Text/GlyphCache.cpp @@ -49,12 +49,14 @@ GlyphCache::GlyphCache(const Vector2i& originalSize, const Vector2i& size, const /** @todo Is there any better way to select proper sized/unsized format on ES2? */ #ifndef MAGNUM_TARGET_GLES2 const TextureFormat internalFormat = TextureFormat::R8; - #else + #elif !defined(MAGNUM_TARGET_WEBGL) TextureFormat internalFormat; if(Context::current()->isExtensionSupported()) { internalFormat = Context::current()->isExtensionSupported() ? TextureFormat::R8 : TextureFormat::Red; } else internalFormat = TextureFormat::Luminance; + #else + const TextureFormat internalFormat = TextureFormat::Luminance; #endif initialize(internalFormat, size); diff --git a/src/Magnum/TextureFormat.h b/src/Magnum/TextureFormat.h index 08b0f35a4..8f2cf65f6 100644 --- a/src/Magnum/TextureFormat.h +++ b/src/Magnum/TextureFormat.h @@ -46,6 +46,7 @@ or WebGL. @see @ref Texture, @ref CubeMapTexture, @ref CubeMapTextureArray */ enum class TextureFormat: GLenum { + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Red component, normalized unsigned, size implementation-dependent. Not * allowed in unemulated @ref Texture::setStorage() "*Texture::setStorage()" @@ -53,7 +54,9 @@ enum class TextureFormat: GLenum { * instead. * @requires_gl30 Extension @extension{ARB,texture_rg} * @requires_gles30 Extension @es_extension{EXT,texture_rg} in OpenGL ES - * 2.0 + * 2.0. + * @requires_webgl20 Not available in WebGL 1.0, see @ref TextureFormat::Luminance + * for an alternative. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref TextureFormat::R8. */ @@ -70,13 +73,17 @@ enum class TextureFormat: GLenum { * @es_extension{EXT,texture_storage} in OpenGL ES 2.0. For texture * storage only, for image specification use @ref TextureFormat::Red * instead. + * @requires_webgl20 Not available in WebGL 1.0, see @ref TextureFormat::Luminance + * for an alternative. */ #ifndef MAGNUM_TARGET_GLES2 R8 = GL_R8, #else R8 = GL_R8_EXT, #endif + #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Red and green component, normalized unsigned, size * implementation-dependent. Not allowed in unemulated @@ -84,7 +91,9 @@ enum class TextureFormat: GLenum { * use @ref TextureFormat::RG8 "TextureFormat::RG8" instead. * @requires_gl30 Extension @extension{ARB,texture_rg} * @requires_gles30 Extension @es_extension{EXT,texture_rg} in OpenGL ES - * 2.0 + * 2.0. + * @requires_webgl20 Not available in WebGL 1.0, see + * @ref TextureFormat::LuminanceAlpha for an alternative. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref TextureFormat::RG8. */ @@ -101,12 +110,15 @@ enum class TextureFormat: GLenum { * @es_extension{EXT,texture_storage} in OpenGL ES 2.0. For texture * storage only, for image specification use @ref TextureFormat::RG * instead. + * @requires_webgl20 Not available in WebGL 1.0, see + * @ref TextureFormat::LuminanceAlpha for an alternative. */ #ifndef MAGNUM_TARGET_GLES2 RG8 = GL_RG8, #else RG8 = GL_RG8_EXT, #endif + #endif /** * RGB, normalized unsigned, size implementation-dependent. Not allowed in @@ -117,17 +129,22 @@ enum class TextureFormat: GLenum { */ RGB = GL_RGB, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * RGB, each component normalized unsigned byte. * @requires_gles30 Extension @es_extension{OES,required_internalformat} * (for image specification) or @es_extension{EXT,texture_storage} - * (for texture storage) in OpenGL ES 2.0 + * (for texture storage) in OpenGL ES 2.0. Use @ref TextureFormat::RGB + * otherwise. + * @requires_webgl20 Not available in WebGL 1.0, use + * @ref TextureFormat::RGB instead. */ #ifndef MAGNUM_TARGET_GLES2 RGB8 = GL_RGB8, #else RGB8 = GL_RGB8_OES, #endif + #endif /** * RGBA, normalized unsigned, size implementation-dependent. Not allowed in @@ -138,23 +155,29 @@ enum class TextureFormat: GLenum { */ RGBA = GL_RGBA, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * RGBA, each component normalized unsigned byte. * @requires_gles30 Extension @es_extension{OES,required_internalformat} * (for image specification) or @es_extension{EXT,texture_storage} - * (for texture storage) in OpenGL ES 2.0 + * (for texture storage) in OpenGL ES 2.0. Use @ref TextureFormat::RGBA + * otherwise. + * @requires_webgl20 Not available in WebGL 1.0, use + * @ref TextureFormat::RGBA instead. */ #ifndef MAGNUM_TARGET_GLES2 RGBA8 = GL_RGBA8, #else RGBA8 = GL_RGBA8_OES, #endif + #endif #ifndef MAGNUM_TARGET_GLES2 /** * Red component, normalized signed byte. * @requires_gl31 Extension @extension{EXT,texture_snorm} * @requires_gles30 Only unsigned formats are available in OpenGL ES 2.0. + * @requires_webgl20 Only unsigned formats are available in WebGL 1.0. */ R8Snorm = GL_R8_SNORM, @@ -162,6 +185,7 @@ enum class TextureFormat: GLenum { * 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. + * @requires_webgl20 Only unsigned formats are available in WebGL 1.0. */ RG8Snorm = GL_RG8_SNORM, @@ -169,6 +193,7 @@ enum class TextureFormat: GLenum { * 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. + * @requires_webgl20 Only unsigned formats are available in WebGL 1.0. */ RGB8Snorm = GL_RGB8_SNORM, @@ -176,6 +201,7 @@ enum class TextureFormat: GLenum { * 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. + * @requires_webgl20 Only unsigned formats are available in WebGL 1.0. */ RGBA8Snorm = GL_RGBA8_SNORM, #endif @@ -185,7 +211,7 @@ enum class TextureFormat: GLenum { * Red component, normalized unsigned short. * @requires_gl30 Extension @extension{ARB,texture_rg} * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ R16 = GL_R16, @@ -193,21 +219,21 @@ enum class TextureFormat: GLenum { * 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. + * ES and WebGL. */ RG16 = GL_RG16, /** * RGB, each component normalized unsigned short. * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ RGB16 = GL_RGB16, /** * RGBA, each component normalized unsigned short. * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ RGBA16 = GL_RGBA16, @@ -215,7 +241,7 @@ enum class TextureFormat: GLenum { * Red component, normalized signed short. * @requires_gl31 Extension @extension{EXT,texture_snorm} * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ R16Snorm = GL_R16_SNORM, @@ -223,7 +249,7 @@ enum class TextureFormat: GLenum { * Red and green component, each normalized signed short. * @requires_gl31 Extension @extension{EXT,texture_snorm} * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ RG16Snorm = GL_RG16_SNORM, @@ -231,7 +257,7 @@ enum class TextureFormat: GLenum { * RGB, each component normalized signed short. * @requires_gl31 Extension @extension{EXT,texture_snorm} * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ RGB16Snorm = GL_RGB16_SNORM, @@ -239,7 +265,7 @@ enum class TextureFormat: GLenum { * RGBA, each component normalized signed short. * @requires_gl31 Extension @extension{EXT,texture_snorm} * @requires_gl Only byte-sized normalized formats are available in OpenGL - * ES. + * ES and WebGL. */ RGBA16Snorm = GL_RGBA16_SNORM, #endif @@ -250,6 +276,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R8UI = GL_R8UI, @@ -258,6 +286,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG8UI = GL_RG8UI, @@ -266,6 +296,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB8UI = GL_RGB8UI, @@ -274,6 +306,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA8UI = GL_RGBA8UI, @@ -282,6 +316,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R8I = GL_R8I, @@ -290,6 +326,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG8I = GL_RG8I, @@ -298,6 +336,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB8I = GL_RGB8I, @@ -306,6 +346,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA8I = GL_RGBA8I, @@ -314,6 +356,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R16UI = GL_R16UI, @@ -322,6 +366,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG16UI = GL_RG16UI, @@ -330,6 +376,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB16UI = GL_RGB16UI, @@ -338,6 +386,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA16UI = GL_RGBA16UI, @@ -346,6 +396,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R16I = GL_R16I, @@ -354,6 +406,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG16I = GL_RG16I, @@ -362,6 +416,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB16I = GL_RGB16I, @@ -370,6 +426,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA16I = GL_RGBA16I, @@ -378,6 +436,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R32UI = GL_R32UI, @@ -386,6 +446,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG32UI = GL_RG32UI, @@ -394,6 +456,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB32UI = GL_RGB32UI, @@ -402,6 +466,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA32UI = GL_RGBA32UI, @@ -410,6 +476,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R32I = GL_R32I, @@ -418,6 +486,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG32I = GL_RG32I, @@ -426,6 +496,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB32I = GL_RGB32I, @@ -434,6 +506,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,texture_integer} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA32I = GL_RGBA32I, @@ -442,6 +516,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R16F = GL_R16F, @@ -450,6 +526,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG16F = GL_RG16F, @@ -458,6 +536,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB16F = GL_RGB16F, @@ -466,6 +546,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA16F = GL_RGBA16F, @@ -474,6 +556,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R32F = GL_R32F, @@ -482,6 +566,8 @@ enum class TextureFormat: GLenum { * @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. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RG32F = GL_RG32F, @@ -490,6 +576,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB32F = GL_RGB32F, @@ -498,6 +586,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{ARB,texture_float} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGBA32F = GL_RGBA32F, #endif @@ -507,8 +597,8 @@ enum class TextureFormat: GLenum { * Luminance, normalized unsigned, single value used for all RGB channels. * Size implementation-dependent. Not allowed in unemulated * @ref Texture::setStorage() "*Texture::setStorage()" calls. - * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use - * @ref TextureFormat::R8 instead. + * @requires_gles20 Not available in OpenGL ES 3.0, WebGL 2.0 or desktop + * OpenGL. Use @ref TextureFormat::R8 instead. * @deprecated_gl Included for compatibility reasons only, use * @ref TextureFormat::R8 instead. */ @@ -519,8 +609,8 @@ enum class TextureFormat: GLenum { * RGB channels, second value is used for alpha channel. Size * implementation-dependent. Not allowed in unemulated * @ref Texture::setStorage() "*Texture::setStorage()" calls. - * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use - * @ref TextureFormat::RG8 instead. + * @requires_gles20 Not available in OpenGL ES 3.0, WebGL 2.0 or desktop + * OpenGL. Use @ref TextureFormat::RG8 instead. * @deprecated_gl Included for compatibility reasons only, use * @ref TextureFormat::RG8 instead. */ @@ -530,20 +620,20 @@ enum class TextureFormat: GLenum { #ifndef MAGNUM_TARGET_GLES /** * RGB, normalized unsigned, red and green component 3bit, blue 2bit. - * @requires_gl Packed 8bit types are not available in OpenGL ES. + * @requires_gl Packed 8bit types are not available in OpenGL ES or WebGL. */ R3B3G2 = GL_R3_G3_B2, /** * RGB, each component normalized unsigned 4bit. - * @requires_gl Packed 12bit types are not available in OpenGL ES. + * @requires_gl Packed 12bit types are not available in OpenGL ES or WebGL. */ RGB4 = GL_RGB4, /** * RGB, each component normalized unsigned 5bit. * @requires_gl Use @ref TextureFormat::RGB5A1 or @ref TextureFormat::RGB565 - * in OpenGL ES. + * in OpenGL ES or WebGL. */ RGB5 = GL_RGB5, #endif @@ -552,11 +642,13 @@ enum class TextureFormat: GLenum { * RGB, normalized unsigned, red and blue component 5bit, green 6bit. * @requires_gles30 Extension @es_extension{OES,required_internalformat} * (for image specification) or @es_extension{EXT,texture_storage} - * (for texture storage) in OpenGL ES 2.0 + * (for texture storage) in OpenGL ES 2.0. + * @requires_webgl20 Not available in WebGL 1.0, see @ref TextureFormat::RGB + * for an alternative. */ RGB565 = GL_RGB565, - #ifndef MAGNUM_TARGET_GLES3 + #if !defined(MAGNUM_TARGET_GLES3) && !defined(MAGNUM_TARGET_WEBGL) /** * RGB, each component normalized unsigned 10bit. * @requires_es_extension Extension @es_extension{EXT,texture_type_2_10_10_10_REV} @@ -564,6 +656,8 @@ enum class TextureFormat: GLenum { * specification) or @es_extension{EXT,texture_storage} (for texture * storage) in OpenGL ES 2.0. Included for compatibility reasons only, * use @ref TextureFormat::RGB10A2 in OpenGL ES 3.0 instead. + * @requires_gles Not available in WebGL, use @ref TextureFormat::RGB10A2 + * instead. */ #ifndef MAGNUM_TARGET_GLES RGB10 = GL_RGB10, @@ -575,7 +669,7 @@ enum class TextureFormat: GLenum { #ifndef MAGNUM_TARGET_GLES /** * RGB, each component normalized unsigned 12bit. - * @requires_gl Packed 36bit types are not available in OpenGL ES. + * @requires_gl Packed 36bit types are not available in OpenGL ES or WebGL. */ RGB12 = GL_RGB12, #endif @@ -586,6 +680,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{EXT,packed_float} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ R11FG11FB10F = GL_R11F_G11F_B10F, @@ -593,6 +689,7 @@ enum class TextureFormat: GLenum { * RGB, unsigned with exponent, each RGB component 9bit, exponent 5bit. * @requires_gl30 Extension @extension{EXT,texture_shared_exponent} * @requires_gles30 Use @ref TextureFormat::RGB in OpenGL ES 2.0 instead. + * @requires_webgl20 Use @ref TextureFormat::RGB in WebGL 1.0 instead. */ RGB9E5 = GL_RGB9_E5, #endif @@ -602,6 +699,7 @@ enum class TextureFormat: GLenum { * unemulated @ref Texture::setStorage() "*Texture::setStorage()" calls, in * that case use @ref TextureFormat::SRGB8 "TextureFormat::SRGB8" instead. * @requires_es_extension Extension @es_extension{EXT,sRGB} + * @requires_webgl_extension Extension @webgl_extension{EXT,sRGB} * @deprecated_gl Prefer to use the exactly specified version of this * format, i.e. @ref TextureFormat::SRGB8. * @todo is this allowed in core? @@ -616,6 +714,7 @@ enum class TextureFormat: GLenum { /** * sRGB, each component normalized unsigned byte. * @requires_gles30 Use @ref TextureFormat::SRGB in OpenGL ES 2.0 instead. + * @requires_webgl20 Use @ref TextureFormat::SRGB in WebGL 1.0 instead. */ SRGB8 = GL_SRGB8, #endif @@ -623,7 +722,7 @@ enum class TextureFormat: GLenum { #ifndef MAGNUM_TARGET_GLES /** * RGBA, normalized unsigned, each component 2bit. - * @requires_gl Packed 8bit types are not available in OpenGL ES. + * @requires_gl Packed 8bit types are not available in OpenGL ES or WebGL. */ RGBA2 = GL_RGBA2, #endif @@ -632,7 +731,10 @@ enum class TextureFormat: GLenum { * RGBA, normalized unsigned, each component 4bit. * @requires_gles30 Extension @es_extension{OES,required_internalformat} * (for image specification) or @es_extension{EXT,texture_storage} - * (for texture storage) in OpenGL ES 2.0 + * (for texture storage) in OpenGL ES 2.0. Use @ref TextureFormat::RGBA + * otherwise. + * @requires_webgl20 Not available in WebGL 1.0, use @ref TextureFormat::RGBA + * instead. */ RGBA4 = GL_RGBA4, @@ -640,22 +742,28 @@ enum class TextureFormat: GLenum { * RGBA, normalized unsigned, each RGB component 5bit, alpha 1bit. * @requires_gles30 Extension @es_extension{OES,required_internalformat} * (for image specification) or @es_extension{EXT,texture_storage} - * (for texture storage) in OpenGL ES 2.0 + * (for texture storage) in OpenGL ES 2.0. Use @ref TextureFormat::RGBA + * otherwise. + * @requires_webgl20 Not available in WebGL 1.0, use @ref TextureFormat::RGBA + * instead. */ RGB5A1 = GL_RGB5_A1, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. * @requires_gles30 Extension @es_extension{EXT,texture_type_2_10_10_10_REV} * and either @es_extension{OES,required_internalformat} (for image * specification) or @es_extension{EXT,texture_storage} (for texture - * storage) in OpenGL ES 2.0 + * storage) in OpenGL ES 2.0. + * @requires_webgl20 Not available in WebGL 1.0. */ #ifndef MAGNUM_TARGET_GLES2 RGB10A2 = GL_RGB10_A2, #else RGB10A2 = GL_RGB10_A2_EXT, #endif + #endif #ifndef MAGNUM_TARGET_GLES2 /** @@ -663,6 +771,8 @@ enum class TextureFormat: GLenum { * @requires_gl33 Extension @extension{ARB,texture_rgb10_a2ui} * @requires_gles30 Only normalized integral formats are available in * OpenGL ES 2.0. + * @requires_webgl20 Only normalized integral formats are available in + * WebGL 1.0. */ RGB10A2UI = GL_RGB10_A2UI, #endif @@ -670,7 +780,7 @@ enum class TextureFormat: GLenum { #ifndef MAGNUM_TARGET_GLES /** * RGBA, each component normalized unsigned 12bit. - * @requires_gl Packed 48bit types are not available in OpenGL ES. + * @requires_gl Packed 48bit types are not available in OpenGL ES or WebGL. */ RGBA12 = GL_RGBA12, #endif @@ -680,6 +790,7 @@ enum class TextureFormat: GLenum { * unemulated @ref Texture::setStorage() "*Texture::setStorage()" calls, in * that case use @ref TextureFormat::SRGB8Alpha8 "TextureFormat::SRGB8Alpha8" instead. * @requires_es_extension Extension @es_extension{EXT,sRGB} + * @requires_webgl_extension Extension @webgl_extension{EXT,sRGB} * @deprecated_gl Prefer to use the exactly specified version of this * format, i.e. @ref TextureFormat::SRGB8Alpha8. * @todo is this allowed in core? @@ -695,6 +806,8 @@ enum class TextureFormat: GLenum { * sRGBA, each component normalized unsigned byte. * @requires_gles30 Use @ref TextureFormat::SRGBAlpha in OpenGL ES 2.0 * instead. + * @requires_webgl20 Use @ref TextureFormat::SRGBAlpha in WebGL 1.0 + * instead. */ SRGB8Alpha8 = GL_SRGB8_ALPHA8, #endif @@ -704,7 +817,8 @@ enum class TextureFormat: GLenum { * Compressed red channel, normalized unsigned. **Not available on * multisample textures.** * @requires_gl30 Extension @extension{ARB,texture_rg} - * @requires_gl Generic texture compression is not available in OpenGL ES. + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. */ CompressedRed = GL_COMPRESSED_RED, @@ -712,21 +826,24 @@ enum class TextureFormat: GLenum { * Compressed red and green channel, normalized unsigned. **Not available * on multisample textures.** * @requires_gl30 Extension @extension{ARB,texture_rg} - * @requires_gl Generic texture compression is not available in OpenGL ES. + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. */ CompressedRG = GL_COMPRESSED_RG, /** * Compressed RGB, normalized unsigned. **Not available on multisample * textures.** - * @requires_gl Generic texture compression is not available in OpenGL ES. + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. */ CompressedRGB = GL_COMPRESSED_RGB, /** * Compressed RGBA, normalized unsigned. **Not available on multisample * textures.** - * @requires_gl Generic texture compression is not available in OpenGL ES. + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. */ CompressedRGBA = GL_COMPRESSED_RGBA, @@ -734,7 +851,8 @@ enum class TextureFormat: GLenum { * RGTC compressed red channel, normalized unsigned. **Not available on * multisample textures.** * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in OpenGL ES. + * @requires_gl Generic texture compression is not available in OpenGL ES + * or WebGL. */ CompressedRedRgtc1 = GL_COMPRESSED_RED_RGTC1, @@ -742,7 +860,8 @@ enum class TextureFormat: GLenum { * RGTC compressed red and green channel, normalized unsigned. **Not * available on multisample textures.** * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in OpenGL ES. + * @requires_gl RGTC texture compression is not available in OpenGL ES or + * WebGL. */ CompressedRGRgtc2 = GL_COMPRESSED_RG_RGTC2, @@ -750,7 +869,8 @@ enum class TextureFormat: GLenum { * RGTC compressed red channel, normalized signed. **Not available on * multisample textures.** * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in OpenGL ES. + * @requires_gl RGTC texture compression is not available in OpenGL ES or + * WebGL. */ CompressedSignedRedRgtc1 = GL_COMPRESSED_SIGNED_RED_RGTC1, @@ -758,7 +878,8 @@ enum class TextureFormat: GLenum { * RGTC compressed red and green channel, normalized signed. **Not * available on multisample textures.** * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl RGTC texture compression is not available in OpenGL ES. + * @requires_gl RGTC texture compression is not available in OpenGL ES or + * WebGL. */ CompressedSignedRGRgtc2 = GL_COMPRESSED_SIGNED_RG_RGTC2, @@ -766,7 +887,8 @@ enum class TextureFormat: GLenum { * BPTC compressed RGB, unsigned float. **Not available on multisample * textures.** * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in OpenGL ES. + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. */ CompressedRGBBptcUnsignedFloat = GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, @@ -774,7 +896,8 @@ enum class TextureFormat: GLenum { * BPTC compressed RGB, signed float. **Not available on multisample * textures.** * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in OpenGL ES. + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. */ CompressedRGBBptcSignedFloat = GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, @@ -782,7 +905,8 @@ enum class TextureFormat: GLenum { * BPTC compressed RGBA, normalized unsigned. **Not available on * multisample textures.** * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in OpenGL ES. + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. */ CompressedRGBABptcUnorm = GL_COMPRESSED_RGBA_BPTC_UNORM, @@ -790,7 +914,8 @@ enum class TextureFormat: GLenum { * BPTC compressed sRGBA, normalized unsigned. **Not available on * multisample textures.** * @requires_gl42 Extension @extension{ARB,texture_compression_bptc} - * @requires_gl BPTC texture compression is not available in OpenGL ES. + * @requires_gl BPTC texture compression is not available in OpenGL ES or + * WebGL. */ CompressedSRGBAlphaBptcUnorm = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, #endif @@ -801,19 +926,25 @@ enum class TextureFormat: GLenum { * "*Texture::setStorage()" calls, in that case use e.g. * @ref TextureFormat::DepthComponent24 "TextureFormat::DepthComponent24" instead. * @requires_gles30 Extension @es_extension{OES,depth_texture} or - * @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0 + * @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0. + * @requires_webgl20 Extension @webgl_extension{WEBGL,depth_texture} in + * WebGL 1.0. * @deprecated_gl Prefer to use the exactly specified version of this * format, e.g. @ref TextureFormat::DepthComponent24. */ DepthComponent = GL_DEPTH_COMPONENT, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * Depth component, 16bit. Not supported in 3D textures. * @requires_gles30 Extension @es_extension{OES,depth_texture} or * @es_extension{ANGLE,depth_texture} and either * @es_extension{OES,required_internalformat} (for image * specification) or @es_extension{EXT,texture_storage} (for texture - * storage) in OpenGL ES 2.0 + * storage) in OpenGL ES 2.0. Use @ref TextureFormat::DepthComponent + * otherwise. + * @requires_webgl20 Not available in WebGL 1.0, use + * @ref TextureFormat::DepthComponent instead. */ DepthComponent16 = GL_DEPTH_COMPONENT16, @@ -821,27 +952,33 @@ enum class TextureFormat: GLenum { * Depth component, 24bit. Not supported in 3D textures. * @requires_gles30 Extension @es_extension{OES,required_internalformat}, * @es_extension{OES,depth_texture} and @es_extension{OES,depth24} in - * OpenGL ES 2.0 + * OpenGL ES 2.0. Use @ref TextureFormat::DepthComponent otherwise. + * @requires_webgl20 Not available in WebGL 1.0, use + * @ref TextureFormat::DepthComponent instead. */ #ifndef MAGNUM_TARGET_GLES2 DepthComponent24 = GL_DEPTH_COMPONENT24, #else DepthComponent24 = GL_DEPTH_COMPONENT24_OES, #endif + #endif + #ifndef MAGNUM_TARGET_WEBGL /** * Depth component, 32bit. Not supported in 3D textures. * @requires_es_extension Extension @es_extension{OES,depth_texture} or * @es_extension{ANGLE,depth_texture} and @es_extension{OES,depth32} * and @es_extension{OES,required_internalformat} (for image * specification) or @es_extension{EXT,texture_storage} (for texture - * storage) in OpenGL ES 2.0 + * storage) in OpenGL ES 2.0. + * @requires_gles Not available in WebGL. */ #ifndef MAGNUM_TARGET_GLES DepthComponent32 = GL_DEPTH_COMPONENT32, #else DepthComponent32 = GL_DEPTH_COMPONENT32_OES, #endif + #endif #ifndef MAGNUM_TARGET_GLES2 /** @@ -849,6 +986,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{ARB,depth_buffer_float} * @requires_gles30 Only integral depth textures are available in OpenGL ES * 2.0. + * @requires_webgl20 Only integral depth textures are available in WebGL + * 1.0. */ DepthComponent32F = GL_DEPTH_COMPONENT32F, #endif @@ -857,7 +996,8 @@ enum class TextureFormat: GLenum { /** * Stencil index, 8bit. Not supported in 3D textures. * @requires_gl44 Extension @extension{ARB,texture_stencil8} - * @requires_gl Only available as renderbuffer format in OpenGL ES. + * @requires_gl Only available as renderbuffer format in OpenGL ES and + * WebGL. */ StencilIndex8 = GL_STENCIL_INDEX8, #endif @@ -870,16 +1010,21 @@ enum class TextureFormat: GLenum { * instead. * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" * @requires_gles30 Extension @es_extension{OES,packed_depth_stencil} or - * @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0 + * @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0. + * @requires_webgl20 Extension @webgl_extension{WEBGL,depth_texture} in + * WebGL 1.0. * @deprecated_gl Prefer to use exactly specified version of this format, * e.g. @ref TextureFormat::Depth24Stencil8. */ #ifndef MAGNUM_TARGET_GLES2 DepthStencil = GL_DEPTH_STENCIL, #else + /* Using OES version even though WebGL 1.0 *has* DEPTH_STENCIL constant, + because there are no such headers for it */ DepthStencil = GL_DEPTH_STENCIL_OES, #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * 24bit depth and 8bit stencil component. Not supported in 3D textures. * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" @@ -888,13 +1033,16 @@ enum class TextureFormat: GLenum { * @es_extension{ANGLE,depth_texture} and either * @es_extension{OES,required_internalformat} (for image * specification) or @es_extension{EXT,texture_storage} (for texture - * storage) in OpenGL ES 2.0 + * storage) in OpenGL ES 2.0. + * @requires_webgl20 Use @ref TextureFormat::DepthStencil in WebGL 1.0 + * instead. */ #ifdef MAGNUM_TARGET_GLES2 Depth24Stencil8 = GL_DEPTH24_STENCIL8_OES #else Depth24Stencil8 = GL_DEPTH24_STENCIL8, #endif + #endif #ifndef MAGNUM_TARGET_GLES2 /** @@ -904,6 +1052,8 @@ enum class TextureFormat: GLenum { * @requires_gl30 Extension @extension{ARB,depth_buffer_float} * @requires_gles30 Only integral depth textures are available in OpenGL ES * 2.0. + * @requires_webgl20 Only integral depth textures are available in WebGL + * 1.0. */ Depth32FStencil8 = GL_DEPTH32F_STENCIL8 #endif diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp index 5994c36e8..a62fff7f8 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp @@ -47,8 +47,14 @@ auto TgaImageConverter::doFeatures() const -> Features { return Feature::Convert Containers::Array TgaImageConverter::doExportToData(const ImageReference2D& image) const { if(image.format() != ColorFormat::RGB && - image.format() != ColorFormat::RGBA && - image.format() != ColorFormat::Red) + image.format() != ColorFormat::RGBA + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + && image.format() != ColorFormat::Red + #endif + #ifdef MAGNUM_TARGET_GLES2 + && image.format() != ColorFormat::Luminance + #endif + ) { Error() << "Trade::TgaImageConverter::exportToData(): unsupported color format" << image.format(); return nullptr; @@ -65,7 +71,21 @@ Containers::Array TgaImageConverter::doExportToData(const ImageReference2D /* Fill header */ auto header = reinterpret_cast(data.begin()); - header->imageType = image.format() == ColorFormat::Red ? 3 : 2; + switch(image.format()) { + case ColorFormat::RGB: + case ColorFormat::RGBA: + header->imageType = 2; + break; + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + case ColorFormat::Red: + #endif + #ifdef MAGNUM_TARGET_GLES2 + case ColorFormat::Luminance: + #endif + header->imageType = 3; + break; + default: CORRADE_ASSERT_UNREACHABLE(); + } header->bpp = pixelSize*8; header->width = UnsignedShort(Utility::Endianness::littleEndian(image.size().x())); header->height = UnsignedShort(Utility::Endianness::littleEndian(image.size().y())); diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h index 1bfb283f7..8845e993d 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h @@ -52,7 +52,8 @@ namespace Magnum { namespace Trade { @brief TGA image converter plugin Supports images with format @ref ColorFormat::RGB, @ref ColorFormat::RGBA or -@ref ColorFormat::Red and type @ref ColorType::UnsignedByte. +@ref ColorFormat::Red (or @ref ColorFormat::Luminance in OpenGL ES 2.0) and +type @ref ColorType::UnsignedByte. This plugin is built if `WITH_TGAIMAGECONVERTER` is enabled when building Magnum. To use dynamic plugin, you need to load `TgaImageConverter` plugin diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp index 5578655fa..b5a13754f 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp @@ -113,11 +113,13 @@ std::optional TgaImporter::doImage2D(UnsignedInt) { /* Grayscale */ } else if(header.imageType == 3) { - #ifdef MAGNUM_TARGET_GLES2 + #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) format = Context::current() && Context::current()->isExtensionSupported() ? ColorFormat::Red : ColorFormat::Luminance; - #else + #elif !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) format = ColorFormat::Red; + #else + format = ColorFormat::Luminance; #endif if(header.bpp != 8) { Error() << "Trade::TgaImporter::image2D(): unsupported grayscale bits-per-pixel:" << header.bpp;