diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 82945cf99..8af499ac2 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -65,7 +65,7 @@ Float AbstractTexture::maxLodBias() { } #endif -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Int AbstractTexture::maxColorSamples() { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) @@ -302,6 +302,7 @@ void AbstractTexture::setBaseLevel(Int level) { } #endif +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setMaxLevel(Int level) { (this->*Context::current()->state().texture->parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 @@ -311,6 +312,7 @@ void AbstractTexture::setMaxLevel(Int level) { #endif , level); } +#endif void AbstractTexture::setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap) { (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap)); @@ -336,6 +338,7 @@ void AbstractTexture::setLodBias(const Float bias) { } #endif +#ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::setBorderColor(const Color4& color) { #ifndef MAGNUM_TARGET_GLES (this->*Context::current()->state().texture->parameterfvImplementation)(GL_TEXTURE_BORDER_COLOR, color.data()); @@ -343,6 +346,7 @@ void AbstractTexture::setBorderColor(const Color4& color) { (this->*Context::current()->state().texture->parameterfvImplementation)(GL_TEXTURE_BORDER_COLOR_NV, color.data()); #endif } +#endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::setBorderColor(const Vector4ui& color) { @@ -358,12 +362,14 @@ void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { (this->*Context::current()->state().texture->setMaxAnisotropyImplementation)(anisotropy); } +#ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::setSRGBDecode(bool decode) { (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT, decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT); } +#endif -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLint b, const GLint a) { #ifndef MAGNUM_TARGET_GLES const GLint rgba[] = {r, g, b, a}; @@ -377,6 +383,7 @@ void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLi } #endif +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setCompareMode(const Sampler::CompareMode mode) { (this->*Context::current()->state().texture->parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 @@ -396,8 +403,9 @@ void AbstractTexture::setCompareFunction(const Sampler::CompareFunction function #endif , GLenum(function)); } +#endif -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::setDepthStencilMode(const Sampler::DepthStencilMode mode) { (this->*Context::current()->state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); } @@ -926,7 +934,7 @@ void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) { (this->*Context::current()->state().texture->parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); } -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values) { bindInternal(); glGetTexLevelParameteriv(_target, level, parameter, values); @@ -969,6 +977,7 @@ void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat } #endif +#if !defined(MAGNUM_TARGET_WEBGL) || defined(MAGNUM_TARGET_GLES2) void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { const ColorFormat format = imageFormatForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat); @@ -1008,12 +1017,14 @@ void AbstractTexture::storageImplementationFallback(const GLsizei levels, const /* No other targets are available */ } else CORRADE_ASSERT_UNREACHABLE(); } +#endif +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) + #elif !defined(CORRADE_TARGET_NACL) glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y()); #else static_cast(levels); @@ -1022,6 +1033,7 @@ void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat CORRADE_ASSERT_UNREACHABLE(); #endif } +#endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { @@ -1034,6 +1046,7 @@ void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat } #endif +#ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { const ColorFormat format = imageFormatForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat); @@ -1063,12 +1076,14 @@ void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureForma /* No other targets are available */ else CORRADE_ASSERT_UNREACHABLE(); } +#endif +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexStorage3D(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) + #elif !defined(CORRADE_TARGET_NACL) glTexStorage3DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); #else static_cast(levels); @@ -1077,6 +1092,7 @@ void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat CORRADE_ASSERT_UNREACHABLE(); #endif } +#endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { @@ -1096,7 +1112,7 @@ void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei sam } #endif -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { bindInternal(); glTexStorage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); @@ -1186,11 +1202,12 @@ void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector2i& } #endif +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) + #elif !defined(CORRADE_TARGET_NACL) glTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); #else static_cast(level); @@ -1202,6 +1219,7 @@ void AbstractTexture::subImageImplementationDefault(GLint level, const Vector3i& CORRADE_ASSERT_UNREACHABLE(); #endif } +#endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::subImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) { @@ -1308,7 +1326,7 @@ Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture } #endif -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLint level) { const Implementation::TextureState& state = *Context::current()->state().texture; @@ -1339,11 +1357,13 @@ void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const (texture.*Context::current()->state().texture->storage2DImplementation)(levels, internalFormat, size); } +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { (texture.*Context::current()->state().texture->storage3DImplementation)(levels, internalFormat, size); } +#endif -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { (texture.*Context::current()->state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); } @@ -1409,6 +1429,7 @@ void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const } #endif +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); @@ -1416,7 +1437,7 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GL texture.bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexImage3D(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), image.data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) + #elif !defined(CORRADE_TARGET_NACL) glTexImage3DOES(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), image.data()); #else static_cast(level); @@ -1425,6 +1446,7 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GL CORRADE_ASSERT_UNREACHABLE(); #endif } +#endif #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { @@ -1434,12 +1456,14 @@ void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GL } #endif +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const ImageReference3D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif (texture.*Context::current()->state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data()); } +#endif #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) { diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 7220bc4e4..d32a5f1ff 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -79,16 +79,17 @@ to not affect active bindings in user units. Texture limits and implementation-defined values (such as @ref maxColorSamples()) are cached, so repeated queries don't result in repeated @fn_gl{Get} calls. -If on desktop GL and @extension{ARB,direct_state_access} (part of OpenGL 4.5) -is available, @ref bind(Int) and @ref unbind(Int) use @fn_gl{BindTextureUnit}. -Otherwise, if @extension{ARB,multi_bind} (part of OpenGL 4.4) is available, -@ref bind(Int) and @ref unbind() uses @fn_gl{BindTextures}. Lastly, if -@extension{EXT,direct_state_access} is available, @fn_gl_extension{BindNamedTexture,EXT,direct_state_access} -function is used to avoid unnecessary calls to @fn_gl{ActiveTexture}. +If @extension{ARB,direct_state_access} (part of OpenGL 4.5) is available, +@ref bind(Int) and @ref unbind(Int) use @fn_gl{BindTextureUnit}. Otherwise, if +@extension{ARB,multi_bind} (part of OpenGL 4.4) is available, @ref bind(Int) +and @ref unbind() uses @fn_gl{BindTextures}. Lastly, if +@extension{EXT,direct_state_access} desktop extension is available, +@fn_gl_extension{BindNamedTexture,EXT,direct_state_access} function is used to +avoid unnecessary calls to @fn_gl{ActiveTexture}. In addition, if either @extension{ARB,direct_state_access} (part of OpenGL 4.5) -or @extension{EXT,direct_state_access} is available, also all texture -configuration and data updating functions use DSA functions to avoid +or @extension{EXT,direct_state_access} desktop extension is available, also all +texture configuration and data updating functions use DSA functions to avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. See respective function documentation for more information. @@ -98,12 +99,12 @@ use @fn_gl{BindTextures} to avoid unnecessary calls to @fn_gl{ActiveTexture}. Otherwise the feature is emulated with sequence of @ref bind(Int)/@ref unbind(Int) calls. -If either @extension{ARB,direct_state_access} or @extension{ARB,robustness} is -available, image reading operations (such as @ref Texture::image()) are -protected from buffer overflow. However, if @extension{ARB,direct_state_access} -is not available and both @extension{EXT,direct_state_access} and -@extension{ARB,robustness} are available, the robust version is preferred over -DSA. +If either @extension{ARB,direct_state_access} (part of OpenGL 4.5) or +@extension{ARB,robustness} desktop extension is available, image reading +operations (such as @ref Texture::image()) are protected from buffer overflow. +However, if @extension{ARB,direct_state_access} is not available and both +@extension{EXT,direct_state_access} and @extension{ARB,robustness} are +available, the robust version is preferred over DSA. To achieve least state changes, fully configure each texture in one run -- method chaining comes in handy -- and try to have often used textures in @@ -159,11 +160,13 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * @see @fn_gl{Get} with @def_gl{MAX_TEXTURE_LOD_BIAS} * @requires_gles30 Texture LOD bias doesn't have * implementation-defined range in OpenGL ES 2.0. + * @requires_webgl20 Texture LOD bias doesn't have + * implementation-defined range in WebGL 1.0. */ static Float maxLodBias(); #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** * @brief Max supported color sample count * @@ -171,7 +174,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * OpenGL calls. If neither extension @extension{ARB,texture_multisample} * (part of OpenGL 3.2) nor OpenGL ES 3.1 is available, returns `0`. * @see @fn_gl{Get} with @def_gl{MAX_COLOR_TEXTURE_SAMPLES} - * @requires_gles30 Not defined in OpenGL ES 2.0 + * @requires_gles30 Not defined in OpenGL ES 2.0. + * @requires_gles Multisample textures are not available in WebGL. */ static Int maxColorSamples(); @@ -182,7 +186,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * OpenGL calls. If neither extension @extension{ARB,texture_multisample} * (part of OpenGL 3.2) nor OpenGL ES 3.1 is available, returns `0`. * @see @fn_gl{Get} with @def_gl{MAX_DEPTH_TEXTURE_SAMPLES} - * @requires_gles30 Not defined in OpenGL ES 2.0 + * @requires_gles30 Not defined in OpenGL ES 2.0. + * @requires_gles Multisample textures are not available in WebGL. */ static Int maxDepthSamples(); @@ -193,7 +198,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * OpenGL calls. If neither extension @extension{ARB,texture_multisample} * (part of OpenGL 3.2) nor OpenGL ES 3.1 is available, returns `0`. * @see @fn_gl{Get} with @def_gl{MAX_INTEGER_SAMPLES} - * @requires_gles30 Not defined in OpenGL ES 2.0 + * @requires_gles30 Not defined in OpenGL ES 2.0. + * @requires_gles Multisample textures are not available in WebGL. */ static Int maxIntegerSamples(); #endif @@ -201,10 +207,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { /** * @brief Unbind any texture from given texture unit * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5), @extension{ARB,multi_bind} (part of OpenGL 4.4) nor - * @extension{EXT,direct_state_access} is available, the texture unit - * is made active before unbinding the texture. + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5), + * @extension{ARB,multi_bind} (part of OpenGL 4.4) nor + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture unit is made active before unbinding the texture. * @note This function is meant to be used only internally from * @ref AbstractShaderProgram subclasses. See its documentation * for more information. @@ -306,10 +312,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { /** * @brief Bind texture to given texture unit * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5), @extension{ARB,multi_bind} (part of OpenGL 4.4) nor - * @extension{EXT,direct_state_access} is available, the texture unit - * is made active before binding the texture. + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5), + * @extension{ARB,multi_bind} (part of OpenGL 4.4) nor + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture unit is made active before binding the texture. * @note This function is meant to be used only internally from * @ref AbstractShaderProgram subclasses. See its documentation * for more information. @@ -340,7 +346,9 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #ifndef MAGNUM_TARGET_GLES2 void setBaseLevel(Int level); #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void setMaxLevel(Int level); + #endif void setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap); void setMagnificationFilter(Sampler::Filter filter); #ifndef MAGNUM_TARGET_GLES2 @@ -350,15 +358,19 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #ifndef MAGNUM_TARGET_GLES void setLodBias(Float bias); #endif + #ifndef MAGNUM_TARGET_WEBGL void setBorderColor(const Color4& color); + #endif #ifndef MAGNUM_TARGET_GLES void setBorderColor(const Vector4i& color); void setBorderColor(const Vector4ui& color); #endif void setMaxAnisotropy(Float anisotropy); + #ifndef MAGNUM_TARGET_WEBGL void setSRGBDecode(bool decode); + #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) template void setSwizzle() { setSwizzleInternal(Implementation::TextureSwizzle::Value, Implementation::TextureSwizzle::Value, @@ -368,9 +380,11 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void setSwizzleInternal(GLint r, GLint g, GLint b, GLint a); #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void setCompareMode(Sampler::CompareMode mode); void setCompareFunction(Sampler::CompareFunction function); - #ifndef MAGNUM_TARGET_GLES2 + #endif + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void setDepthStencilMode(Sampler::DepthStencilMode mode); #endif void invalidateImage(Int level); @@ -440,7 +454,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat); void MAGNUM_LOCAL setMaxAnisotropyImplementationExt(GLfloat anisotropy); - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLint level, GLenum parameter, GLint* values); @@ -461,15 +475,23 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); #endif + #if !defined(MAGNUM_TARGET_WEBGL) || defined(MAGNUM_TARGET_GLES2) void MAGNUM_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector2i& size); + #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void MAGNUM_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector2i& size); + #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Vector2i& size); void MAGNUM_LOCAL storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #endif + #ifndef MAGNUM_TARGET_WEBGL void MAGNUM_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size); + #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void MAGNUM_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector3i& size); + #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Vector3i& size); void MAGNUM_LOCAL storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector3i& size); @@ -478,7 +500,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); #endif #ifndef MAGNUM_TARGET_GLES @@ -512,7 +534,9 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); + #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); @@ -571,7 +595,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { }; #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) static Vector2i imageSize(AbstractTexture& texture, GLint level); #endif @@ -579,7 +603,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) static void setStorageMultisample(AbstractTexture& texture, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedSampleLocations); #endif @@ -602,6 +626,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { static void invalidateSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, const Vector2i& size); }; template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #ifdef MAGNUM_BUILD_DEPRECATED enum class Target: GLenum { #ifndef MAGNUM_TARGET_GLES2 @@ -619,9 +644,11 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { #ifndef MAGNUM_TARGET_GLES2 static Vector3i imageSize(AbstractTexture& texture, GLint level); #endif + #endif static void setWrapping(AbstractTexture& texture, const Array3D& wrapping); + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #ifndef MAGNUM_TARGET_GLES @@ -637,6 +664,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { #ifndef MAGNUM_TARGET_GLES2 static void setSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, BufferImage3D& image); #endif + #endif static void invalidateSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, const Vector3i& size); }; diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index 4ba1d6827..bd5bb77e8 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -187,9 +187,9 @@ documentation for more information about usage in shaders. ## Performance optimizations -If on desktop GL and either @extension{ARB,direct_state_access} (part of OpenGL -4.5) or @extension{EXT,direct_state_access} is available, @ref setBuffer() -functions use DSA to avoid unnecessary calls to @fn_gl{ActiveTexture} and +If either @extension{ARB,direct_state_access} (part of OpenGL 4.5) or +@extension{EXT,direct_state_access} is available, @ref setBuffer() functions +use DSA to avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. See @ref AbstractTexture-performance-optimization "relevant section in AbstractTexture documentation" and respective function documentation for more information. @@ -197,7 +197,7 @@ and respective function documentation for more information. @see @ref Texture, @ref TextureArray, @ref CubeMapTexture, @ref CubeMapTextureArray, @ref RectangleTexture, @ref MultisampleTexture @requires_gl31 Extension @extension{ARB,texture_buffer_object} -@requires_gl Texture buffers are not available in OpenGL ES. +@requires_gl Texture buffers are not available in OpenGL ES or WebGL. */ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { friend Implementation::TextureState; @@ -227,7 +227,7 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { * @brief Constructor * * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) is not supported, the texture is created on + * (part of OpenGL 4.5) is not available, the texture is created on * first use. * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_BUFFER}, eventually * @fn_gl{GenTextures} diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 110b7afc6..35bcb09a9 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -154,11 +154,10 @@ if(NOT TARGET_GLES) RectangleTexture.h) endif() -# Non-ES2 stuff +# OpenGL ES 3.0 and WebGL 2.0 stuff if(NOT TARGET_GLES2) list(APPEND Magnum_SRCS BufferImage.cpp - MultisampleTexture.cpp TextureArray.cpp TransformFeedback.cpp @@ -166,7 +165,6 @@ if(NOT TARGET_GLES2) list(APPEND Magnum_HEADERS BufferImage.h - MultisampleTexture.h PrimitiveQuery.h TextureArray.h TransformFeedback.h) @@ -176,7 +174,7 @@ if(NOT TARGET_GLES2) endif() -# Non-WebGL stuff +# Desktop and OpenGL ES stuff that is not available in WebGL if(NOT TARGET_WEBGL) list(APPEND Magnum_SRCS DebugOutput.cpp @@ -189,6 +187,11 @@ if(NOT TARGET_WEBGL) list(APPEND Magnum_PRIVATE_HEADERS Implementation/DebugState.h) + if(NOT TARGET_GLES2) + list(APPEND Magnum_SRCS MultisampleTexture.cpp) + list(APPEND Magnum_HEADERS MultisampleTexture.h) + endif() + if(BUILD_DEPRECATED) list(APPEND Magnum_HEADERS DebugMarker.h diff --git a/src/Magnum/CubeMapTexture.cpp b/src/Magnum/CubeMapTexture.cpp index ba3f119e3..6753d24c6 100644 --- a/src/Magnum/CubeMapTexture.cpp +++ b/src/Magnum/CubeMapTexture.cpp @@ -49,7 +49,7 @@ Vector2i CubeMapTexture::maxSize() { return Vector2i{Implementation::maxCubeMapTextureSideSize()}; } -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Vector2i CubeMapTexture::imageSize(const Int level) { return (this->*Context::current()->state().texture->getCubeImageSizeImplementation)(level); } @@ -153,7 +153,7 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Coordinate coordinate, const I } #endif -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Vector2i CubeMapTexture::getImageSizeImplementationDefault(const Int level) { Vector2i size; bindInternal(); diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index f3f67cf41..cd8d845eb 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -106,7 +106,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @brief Constructor * * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) is not supported, the texture is created on + * (part of OpenGL 4.5) is not available, the texture is created on * first use. * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_CUBE_MAP}, * eventually @fn_gl{GenTextures} @@ -120,6 +120,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref Texture::setBaseLevel() for more information. * @requires_gles30 Base level is always `0` in OpenGL ES 2.0. + * @requires_webgl20 Base level is always `0` in WebGL 1.0. */ CubeMapTexture& setBaseLevel(Int level) { AbstractTexture::setBaseLevel(level); @@ -127,6 +128,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { } #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * @copybrief Texture::setMaxLevel() * @return Reference to self (for method chaining) @@ -135,11 +137,13 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gles30 Extension @es_extension{APPLE,texture_max_level}, * otherwise the max level is always set to largest possible value * in OpenGL ES 2.0. + * @requires_webgl20 Always set to largest possible value in WebGL 1.0. */ CubeMapTexture& setMaxLevel(Int level) { AbstractTexture::setMaxLevel(level); return *this; } + #endif /** * @copybrief Texture::setMinificationFilter() @@ -171,6 +175,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::setMinLod() for more information. * @requires_gles30 Texture LOD parameters are not available in OpenGL * ES 2.0. + * @requires_webgl20 Texture LOD parameters are not available in WebGL + * 1.0. */ CubeMapTexture& setMinLod(Float lod) { AbstractTexture::setMinLod(lod); @@ -184,6 +190,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::setMaxLod() for more information. * @requires_gles30 Texture LOD parameters are not available in OpenGL * ES 2.0. + * @requires_webgl20 Texture LOD parameters are not available in WebGL + * 1.0. */ CubeMapTexture& setMaxLod(Float lod) { AbstractTexture::setMaxLod(lod); @@ -198,7 +206,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref Texture::setLodBias() for more information. * @requires_gl Texture LOD bias can be specified only directly in - * fragment shader in OpenGL ES. + * fragment shader in OpenGL ES and WebGL. */ CubeMapTexture& setLodBias(Float bias) { AbstractTexture::setLodBias(bias); @@ -217,6 +225,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @copybrief Texture::setBorderColor(const Color4&) * @return Reference to self (for method chaining) @@ -224,11 +233,13 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::setBorderColor(const Color4&) for more * information. * @requires_es_extension Extension @es_extension{NV,texture_border_clamp} + * @requires_gles Border clamp is not available in WebGL. */ CubeMapTexture& setBorderColor(const Color4& color) { AbstractTexture::setBorderColor(color); return *this; } + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -238,8 +249,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::setBorderColor(const Vector4ui&) for more * information. * @requires_gl30 Extension @extension{EXT,texture_integer} - * @requires_gl Border is available only for float textures in OpenGL - * ES. + * @requires_gl Border clamp is available only for float textures in + * OpenGL ES. Border clamp is not available in WebGL. */ CubeMapTexture& setBorderColor(const Vector4ui& color) { AbstractTexture::setBorderColor(color); @@ -248,8 +259,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { /** @overload * @requires_gl30 Extension @extension{EXT,texture_integer} - * @requires_gl Border is available only for float textures in OpenGL - * ES. + * @requires_gl Border clamp is available only for float textures in + * OpenGL ES. Border clamp is not available in WebGL. */ CubeMapTexture& setBorderColor(const Vector4i& color) { AbstractTexture::setBorderColor(color); @@ -268,6 +279,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @copybrief Texture::setSRGBDecode() * @return Reference to self (for method chaining) @@ -277,13 +289,15 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_es_extension OpenGL ES 3.0 or extension * @es_extension{EXT,sRGB} and * @es_extension2{EXT,texture_sRGB_decode,texture_sRGB_decode} + * @requires_gles SRGB decode is not available in WebGL. */ CubeMapTexture& setSRGBDecode(bool decode) { AbstractTexture::setSRGBDecode(decode); return *this; } + #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** * @copybrief Texture::setSwizzle() * @return Reference to self (for method chaining) @@ -291,6 +305,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::setSwizzle() for more information. * @requires_gl33 Extension @extension{ARB,texture_swizzle} * @requires_gles30 Texture swizzle is not available in OpenGL ES 2.0. + * @requires_gles Texture swizzle is not available in WebGL. */ template CubeMapTexture& setSwizzle() { AbstractTexture::setSwizzle(); @@ -298,13 +313,16 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { } #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * @copybrief Texture::setCompareMode() * @return Reference to self (for method chaining) * * See @ref Texture::setCompareMode() for more information. * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} and - * @es_extension{NV,shadow_samplers_cube} + * @es_extension{NV,shadow_samplers_cube} in OpenGL ES 2.0. + * @requires_webgl20 Depth texture comparison is not available in WebGL + * 1.0. */ CubeMapTexture& setCompareMode(Sampler::CompareMode mode) { AbstractTexture::setCompareMode(mode); @@ -317,14 +335,17 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref Texture::setCompareFunction() for more information. * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} and - * @es_extension{NV,shadow_samplers_cube} + * @es_extension{NV,shadow_samplers_cube} in OpenGL ES 2.0. + * @requires_webgl20 Depth texture comparison is not available in WebGL + * 1.0. */ CubeMapTexture& setCompareFunction(Sampler::CompareFunction function) { AbstractTexture::setCompareFunction(function); return *this; } + #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** * @copybrief Texture::setDepthStencilMode() * @return Reference to self (for method chaining) @@ -333,6 +354,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gl43 Extension @extension{ARB,stencil_texturing} * @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0 * and older. + * @requires_gles Stencil texturing is not available in WebGL. */ CubeMapTexture& setDepthStencilMode(Sampler::DepthStencilMode mode) { AbstractTexture::setDepthStencilMode(mode); @@ -352,16 +374,18 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { return *this; } - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** * @copybrief Texture::imageSize() * - * If on OpenGL ES or @extension{ARB,direct_state_access} (part of - * OpenGL 4.5) is not available, it is assumed that faces have the same - * size and just the size of @ref Coordinate::PositiveX face is - * queried. See @ref Texture::imageSize() for more information. + * If @extension{ARB,direct_state_access} (part of OpenGL 4.5) is not + * available, it is assumed that faces have the same size and just the + * size of @ref Coordinate::PositiveX face is queried. See + * @ref Texture::imageSize() for more information. * @requires_gles31 Texture image size queries are not available in * OpenGL ES 3.0 and older. + * @requires_gles Texture image size queries are not available in + * WebGL. */ Vector2i imageSize(Int level); @@ -387,8 +411,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @def_gl{TEXTURE_WIDTH}, @def_gl{TEXTURE_HEIGHT}, then * @fn_gl{GetTextureImage} * @requires_gl45 Extension @extension{ARB,direct_state_access} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void image(Int level, Image3D& image); @@ -406,8 +430,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref image(Int, Image3D&) for more information. * @requires_gl45 Extension @extension{ARB,direct_state_access} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void image(Int level, BufferImage3D& image, BufferUsage usage); @@ -444,8 +468,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @fn_gl_extension{GetnTexImage,ARB,robustness}, * @fn_gl_extension{GetTextureImage,EXT,direct_state_access}, * eventually @fn_gl{GetTexImage} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void image(Coordinate coordinate, Int level, Image2D& image); @@ -462,8 +486,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @brief Read given mip level and coordinate of texture to buffer image * * See @ref image(Coordinate, Int, Image2D&) for more information. - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void image(Coordinate coordinate, Int level, BufferImage2D& image, BufferUsage usage); @@ -482,8 +506,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::subImage(Int, const RangeTypeFor&, Image&) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void subImage(Int level, const Range3Di& range, Image3D& image) { AbstractTexture::subImage<3>(level, range, image); @@ -504,8 +528,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * See @ref Texture::subImage(Int, const RangeTypeFor&, BufferImage&, BufferUsage) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void subImage(Int level, const Range3Di& range, BufferImage3D& image, BufferUsage usage) { AbstractTexture::subImage<3>(level, range, image, usage); @@ -539,6 +563,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ @@ -550,6 +576,8 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ @@ -569,22 +597,22 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * @see @ref setStorage(), @fn_gl2{TextureSubImage3D,TexSubImage3D} * @requires_gl45 Extension @extension{ARB,direct_state_access} - * @requires_gl In OpenGL ES you need to set image for each face - * separately. + * @requires_gl In OpenGL ES and WebGL you need to set image for each + * face separately. */ CubeMapTexture& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image); /** @overload * @requires_gl45 Extension @extension{ARB,direct_state_access} - * @requires_gl In OpenGL ES you need to set image for each face - * separately. + * @requires_gl In OpenGL ES and WebGL you need to set image for each + * face separately. */ CubeMapTexture& setSubImage(Int level, const Vector3i& offset, BufferImage3D& image); /** @overload * @requires_gl45 Extension @extension{ARB,direct_state_access} - * @requires_gl In OpenGL ES you need to set image for each face - * separately. + * @requires_gl In OpenGL ES and WebGL you need to set image for each + * face separately. */ CubeMapTexture& setSubImage(Int level, const Vector3i& offset, BufferImage3D&& image) { return setSubImage(level, offset, image); @@ -603,12 +631,16 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. */ CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D& image); /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. */ CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D&& image) { return setSubImage(coordinate, level, offset, image); @@ -660,11 +692,13 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { #endif private: + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Vector2i MAGNUM_LOCAL getImageSizeImplementationDefault(Int level); #ifndef MAGNUM_TARGET_GLES Vector2i MAGNUM_LOCAL getImageSizeImplementationDSA(Int level); Vector2i MAGNUM_LOCAL getImageSizeImplementationDSAEXT(Int level); #endif + #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL getImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index 57955eb0d..d6870f063 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -80,7 +80,7 @@ the six sides of the cube map, fourth part is layer in the array. See @ref Texture, @ref TextureArray, @ref RectangleTexture, @ref BufferTexture, @ref MultisampleTexture @requires_gl40 Extension @extension{ARB,texture_cube_map_array} -@requires_gl Cube map texture arrays are not available in OpenGL ES. +@requires_gl Cube map texture arrays are not available in OpenGL ES or WebGL. */ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { public: @@ -88,7 +88,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { * @brief Constructor * * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) is not supported, the texture is created on + * (part of OpenGL 4.5) is not available, the texture is created on * first use. * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_CUBE_MAP_ARRAY}, * eventually @fn_gl{GenTextures} diff --git a/src/Magnum/Implementation/TextureState.cpp b/src/Magnum/Implementation/TextureState.cpp index f339d2242..ac60559af 100644 --- a/src/Magnum/Implementation/TextureState.cpp +++ b/src/Magnum/Implementation/TextureState.cpp @@ -38,7 +38,11 @@ namespace Magnum { namespace Implementation { -TextureState::TextureState(Context& context, std::vector& extensions): maxSize{}, max3DSize{}, maxCubeMapSize{}, +TextureState::TextureState(Context& context, std::vector& extensions): maxSize{}, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + max3DSize{}, + #endif + maxCubeMapSize{}, #ifndef MAGNUM_TARGET_GLES2 maxArrayLayers{}, #endif @@ -165,7 +169,7 @@ TextureState::TextureState(Context& context, std::vector& extension parameterIuivImplementation = &AbstractTexture::parameterIImplementationDefault; parameterIivImplementation = &AbstractTexture::parameterIImplementationDefault; #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDefault; #endif mipmapImplementation = &AbstractTexture::mipmapImplementationDefault; @@ -173,14 +177,16 @@ TextureState::TextureState(Context& context, std::vector& extension subImage1DImplementation = &AbstractTexture::subImageImplementationDefault; #endif subImage2DImplementation = &AbstractTexture::subImageImplementationDefault; + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) subImage3DImplementation = &AbstractTexture::subImageImplementationDefault; + #endif #ifndef MAGNUM_TARGET_GLES setBufferImplementation = &BufferTexture::setBufferImplementationDefault; setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDefault; #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) getCubeImageSizeImplementation = &CubeMapTexture::getImageSizeImplementationDefault; #endif cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDefault; @@ -232,7 +238,8 @@ TextureState::TextureState(Context& context, std::vector& extension } else getCubeImageImplementation = &CubeMapTexture::getImageImplementationDefault; #endif - /* Texture storage implementation */ + /* Texture storage implementation for desktop and ES */ + #ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) @@ -275,6 +282,16 @@ TextureState::TextureState(Context& context, std::vector& extension } #endif + /* Texture storage implementation for WebGL 1.0 */ + #elif defined(MAGNUM_TARGET_GLES2) + storage2DImplementation = &AbstractTexture::storageImplementationFallback; + + /* Texture storage implementation for WebGL 2.0 */ + #else + storage2DImplementation = &AbstractTexture::storageImplementationDefault; + storage3DImplementation = &AbstractTexture::storageImplementationDefault; + #endif + #ifndef MAGNUM_TARGET_GLES /* Storage implementation for multisample textures. The fallback doesn't have DSA alternative, so it must be handled specially. */ @@ -295,7 +312,7 @@ TextureState::TextureState(Context& context, std::vector& extension storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationFallback; storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationFallback; } - #elif !defined(MAGNUM_TARGET_GLES2) + #elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault; #endif diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index e66aca81c..44b1454d6 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -53,7 +53,7 @@ struct TextureState { void(AbstractTexture::*parameterIivImplementation)(GLenum, const GLint*); #endif void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat); - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void(AbstractTexture::*getLevelParameterivImplementation)(GLint, GLenum, GLint*); #endif void(AbstractTexture::*mipmapImplementation)(); @@ -61,8 +61,10 @@ struct TextureState { void(AbstractTexture::*storage1DImplementation)(GLsizei, TextureFormat, const Math::Vector<1, GLsizei>&); #endif void(AbstractTexture::*storage2DImplementation)(GLsizei, TextureFormat, const Vector2i&); + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void(AbstractTexture::*storage3DImplementation)(GLsizei, TextureFormat, const Vector3i&); - #ifndef MAGNUM_TARGET_GLES2 + #endif + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void(AbstractTexture::*storage2DMultisampleImplementation)(GLsizei, TextureFormat, const Vector2i&, GLboolean); #endif #ifndef MAGNUM_TARGET_GLES @@ -73,7 +75,9 @@ struct TextureState { void(AbstractTexture::*subImage1DImplementation)(GLint, const Math::Vector<1, GLint>&, const Math::Vector<1, GLsizei>&, ColorFormat, ColorType, const GLvoid*); #endif void(AbstractTexture::*subImage2DImplementation)(GLint, const Vector2i&, const Vector2i&, ColorFormat, ColorType, const GLvoid*); + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void(AbstractTexture::*subImage3DImplementation)(GLint, const Vector3i&, const Vector3i&, ColorFormat, ColorType, const GLvoid*); + #endif void(AbstractTexture::*invalidateImageImplementation)(GLint); void(AbstractTexture::*invalidateSubImageImplementation)(GLint, const Vector3i&, const Vector3i&); @@ -82,7 +86,7 @@ struct TextureState { void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Vector2i(CubeMapTexture::*getCubeImageSizeImplementation)(Int); #endif #ifndef MAGNUM_TARGET_GLES @@ -91,7 +95,9 @@ struct TextureState { void(CubeMapTexture::*cubeSubImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, const Vector2i&, ColorFormat, ColorType, const GLvoid*); GLint maxSize, + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) max3DSize, + #endif maxCubeMapSize; #ifndef MAGNUM_TARGET_GLES2 GLint maxArrayLayers; diff --git a/src/Magnum/Implementation/maxTextureSize.cpp b/src/Magnum/Implementation/maxTextureSize.cpp index 19599edd3..ed4cc2e5f 100644 --- a/src/Magnum/Implementation/maxTextureSize.cpp +++ b/src/Magnum/Implementation/maxTextureSize.cpp @@ -41,6 +41,7 @@ GLint maxTextureSideSize() { return value; } +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) GLint max3DTextureDepth() { GLint& value = Context::current()->state().texture->max3DSize; @@ -53,6 +54,7 @@ GLint max3DTextureDepth() { return value; } +#endif #ifndef MAGNUM_TARGET_GLES2 GLint maxTextureArrayLayers() { diff --git a/src/Magnum/Implementation/maxTextureSize.h b/src/Magnum/Implementation/maxTextureSize.h index ed9929245..377dfe559 100644 --- a/src/Magnum/Implementation/maxTextureSize.h +++ b/src/Magnum/Implementation/maxTextureSize.h @@ -30,7 +30,9 @@ namespace Magnum { namespace Implementation { GLint maxTextureSideSize(); +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) GLint max3DTextureDepth(); +#endif #ifndef MAGNUM_TARGET_GLES2 GLint maxTextureArrayLayers(); #endif diff --git a/src/Magnum/MultisampleTexture.h b/src/Magnum/MultisampleTexture.h index cc07b68c9..f0bd5732f 100644 --- a/src/Magnum/MultisampleTexture.h +++ b/src/Magnum/MultisampleTexture.h @@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE. */ -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** @file * @brief Class @ref Magnum::MultisampleTexture, typedef @ref Magnum::MultisampleTexture2D, @ref Magnum::MultisampleTexture2DArray */ @@ -35,7 +35,7 @@ #include "Magnum/DimensionTraits.h" #include "Magnum/Math/Vector3.h" -#ifndef MAGNUM_TARGET_GLES2 +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) namespace Magnum { namespace Implementation { @@ -90,7 +90,8 @@ shaders. @requires_gles31 Multisample textures are not available in OpenGL ES 3.0 and older. @requires_gl 2D array multisample textures are not available in OpenGL ES, only - 2D ones. + 2D ones. No multisample textures are available in WebGL. +@requires_gles Multisample textures are not available in WebGL. */ template class MultisampleTexture: public AbstractTexture { public: @@ -114,7 +115,7 @@ template class MultisampleTexture: public AbstractTextur * @brief Constructor * * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) is not supported, the texture is created on + * (part of OpenGL 4.5) is not available, the texture is created on * first use. * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_2D_MULTISAMPLE} or * @def_gl{TEXTURE_2D_MULTISAMPLE_ARRAY}, eventually @@ -133,12 +134,13 @@ template class MultisampleTexture: public AbstractTextur * After calling this function the texture is immutable and calling * @ref setStorage() again is not allowed. * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). If - * @extension{ARB,texture_storage_multisample} (part of OpenGL 4.3) is - * not available, the texture is bound and the feature is emulated - * using plain @extension{ARB,texture_multisample} functionality. + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is + * available, the texture is bound before the operation (if not + * already). If @extension{ARB,texture_storage_multisample} (part of + * OpenGL 4.3) is not available, the texture is bound and the feature + * is emulated using plain @extension{ARB,texture_multisample} + * functionality. * @see @ref maxSize(), @ref maxColorSamples(), @ref maxDepthSamples(), * @ref maxIntegerSamples(), @fn_gl2{TextureStorage2DMultisample,TexStorage2DMultisample} / * @fn_gl2{TextureStorage3DMultisample,TexStorage3DMultisample}, @@ -211,6 +213,7 @@ template class MultisampleTexture: public AbstractTextur @requires_gl32 Extension @extension{ARB,texture_multisample} @requires_gles31 Multisample textures are not available in OpenGL ES 3.0 and older. +@requires_gles Multisample textures are not available in WebGL. */ typedef MultisampleTexture<2> MultisampleTexture2D; @@ -220,13 +223,14 @@ typedef MultisampleTexture<2> MultisampleTexture2D; @requires_gl32 Extension @extension{ARB,texture_multisample} @requires_gl Only @ref MultisampleTexture2D is available in OpenGL ES. + No multisample textures are available in WebGL. */ typedef MultisampleTexture<3> MultisampleTexture2DArray; #endif } #else -#error this header is not available in OpenGL ES 2.0 build +#error this header is not available in OpenGL ES 2.0 and WebGL build #endif #endif diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index d33e3086f..72c518243 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -66,7 +66,7 @@ documentation for more information about usage in shaders. @see @ref Texture, @ref TextureArray, @ref CubeMapTexture, @ref CubeMapTextureArray, @ref BufferTexture, @ref MultisampleTexture @requires_gl31 Extension @extension{ARB,texture_rectangle} -@requires_gl Rectangle textures are not available in OpenGL ES. +@requires_gl Rectangle textures are not available in OpenGL ES and WebGL. */ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { public: @@ -84,7 +84,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { * @brief Constructor * * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) is not supported, the texture is created on + * (part of OpenGL 4.5) is not available, the texture is created on * first use. * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_RECTANGLE}, * eventually @fn_gl{GenTextures} diff --git a/src/Magnum/Sampler.cpp b/src/Magnum/Sampler.cpp index de494480b..39e3f8838 100644 --- a/src/Magnum/Sampler.cpp +++ b/src/Magnum/Sampler.cpp @@ -90,7 +90,9 @@ Debug operator<<(Debug debug, const Sampler::Wrapping value) { _c(Repeat) _c(MirroredRepeat) _c(ClampToEdge) + #ifndef MAGNUM_TARGET_WEBGL _c(ClampToBorder) + #endif #ifndef MAGNUM_TARGET_GLES _c(MirrorClampToEdge) #endif @@ -100,6 +102,7 @@ Debug operator<<(Debug debug, const Sampler::Wrapping value) { return debug << "Sampler::Wrapping::(invalid)"; } +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Debug operator<<(Debug debug, const Sampler::CompareMode value) { switch(value) { #define _c(value) case Sampler::CompareMode::value: return debug << "Sampler::CompareMode::" #value; @@ -127,6 +130,7 @@ Debug operator<<(Debug debug, const Sampler::CompareFunction value) { return debug << "Sampler::CompareFunction::(invalid)"; } +#endif #ifndef MAGNUM_TARGET_GLES Debug operator<<(Debug debug, const Sampler::DepthStencilMode value) { diff --git a/src/Magnum/Sampler.h b/src/Magnum/Sampler.h index d97acb1aa..8ffd5b212 100644 --- a/src/Magnum/Sampler.h +++ b/src/Magnum/Sampler.h @@ -58,7 +58,11 @@ class MAGNUM_EXPORT Sampler { * @es_extension2{OES,texture_half_float_linear,OES_texture_float_linear} * for linear interpolation of textures with * @ref TextureFormat::HalfFloat / @ref TextureFormat::Float - * in OpenGL ES 2.0 + * in OpenGL ES 2.0. + * @requires_webgl20 Extension @webgl_extension{OES,texture_float_linear} + * / @webgl_extension{OES,texture_half_float_linear} for + * linear interpolation of textures with @ref TextureFormat::HalfFloat + * / @ref TextureFormat::Float in WebGL 1.0. */ Linear = GL_LINEAR }; @@ -84,6 +88,10 @@ class MAGNUM_EXPORT Sampler { * for linear interpolation of textures with * @ref TextureFormat::HalfFloat / @ref TextureFormat::Float * in OpenGL ES 2.0. + * @requires_webgl20 Extension @webgl_extension{OES,texture_float_linear} + * / @webgl_extension{OES,texture_half_float_linear} for + * linear interpolation of textures with @ref TextureFormat::HalfFloat + * / @ref TextureFormat::Float in WebGL 1.0. */ Linear = GL_NEAREST_MIPMAP_LINEAR & ~GL_NEAREST }; @@ -108,17 +116,20 @@ class MAGNUM_EXPORT Sampler { */ ClampToEdge = GL_CLAMP_TO_EDGE, + #ifndef MAGNUM_TARGET_WEBGL /** * Clamp to border color. Coordinates out of range will be clamped * to border color (set with * @ref Texture::setBorderColor() "*Texture::setBorderColor()"). * @requires_es_extension Extension @es_extension{NV,texture_border_clamp} + * @requires_gles Border clamp is not available in WebGL. */ #ifndef MAGNUM_TARGET_GLES ClampToBorder = GL_CLAMP_TO_BORDER, #else ClampToBorder = GL_CLAMP_TO_BORDER_NV, #endif + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -127,18 +138,23 @@ class MAGNUM_EXPORT Sampler { * @requires_gl44 Extension @extension{ARB,texture_mirror_clamp_to_edge}, * @extension{ATI,texture_mirror_once} or @extension{EXT,texture_mirror_clamp} * @requires_gl Only separate @ref Wrapping::MirroredRepeat or - * @ref Wrapping::ClampToEdge is available in OpenGL ES. + * @ref Wrapping::ClampToEdge is available in OpenGL ES and + * WebGL. */ MirrorClampToEdge = GL_MIRROR_CLAMP_TO_EDGE #endif }; + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * @brief Depth texture comparison mode * * @see @ref CompareFunction, * @ref Texture::setCompareMode() "*Texture::setCompareMode()" - * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} + * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} in + * OpenGL ES 2.0. + * @requires_webgl20 Depth texture comparison is not available in WebGL + * 1.0. */ enum class CompareMode: GLenum { /** Directly output the depth value */ @@ -160,7 +176,10 @@ class MAGNUM_EXPORT Sampler { * @ref CompareMode::CompareRefToTexture. * @see @ref Texture::setCompareFunction() "*Texture::setCompareFunction()", * @ref Texture::setCompareMode() "*Texture::setCompareMode()" - * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} + * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} in + * OpenGL ES 2.0. + * @requires_webgl20 Depth texture comparison is not available in WebGL + * 1.0. */ enum class CompareFunction: GLenum { Never = GL_NEVER, /**< Always `0.0` */ @@ -202,15 +221,17 @@ class MAGNUM_EXPORT Sampler { */ Greater = GL_GREATER }; + #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** * @brief Depth/stencil texture mode * * @see @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" * @requires_gl43 Extension @extension{ARB,stencil_texturing} * @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0 - * and older + * and older. + * @requires_gles Stencil texturing is not available in WebGL. */ enum class DepthStencilMode: GLenum { /** Sample depth component */ @@ -241,11 +262,13 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Sampler::Mipmap value); /** @debugoperatorclassenum{Magnum::Sampler,Magnum::Sampler::Wrapping} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Sampler::Wrapping value); +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** @debugoperatorclassenum{Magnum::Sampler,Magnum::Sampler::CompareMode} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Sampler::CompareMode value); /** @debugoperatorclassenum{Magnum::Sampler,Magnum::Sampler::CompareFunction} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Sampler::CompareFunction value); +#endif #ifndef MAGNUM_TARGET_GLES /** @debugoperatorclassenum{Magnum::Sampler,Magnum::Sampler::DepthStencilMode} */ diff --git a/src/Magnum/Texture.cpp b/src/Magnum/Texture.cpp index 76a305cd8..b09e6fc90 100644 --- a/src/Magnum/Texture.cpp +++ b/src/Magnum/Texture.cpp @@ -50,6 +50,7 @@ template MAGNUM_EXPORT Math::Vector<1, Int> maxTextureSize<1>(); #endif template MAGNUM_EXPORT Vector2i maxTextureSize<2>(); +#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) template<> MAGNUM_EXPORT Vector3i maxTextureSize<3>() { #ifdef MAGNUM_TARGET_GLES2 if(!Context::current()->isExtensionSupported()) @@ -57,6 +58,7 @@ template<> MAGNUM_EXPORT Vector3i maxTextureSize<3>() { #endif return {Vector2i(Implementation::maxTextureSideSize()), Implementation::max3DTextureDepth()}; } +#endif } diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 117b10964..c8d164afc 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -44,6 +44,7 @@ namespace Implementation { template<> constexpr GLenum textureTarget<1>() { return GL_TEXTURE_1D; } #endif template<> constexpr GLenum textureTarget<2>() { return GL_TEXTURE_2D; } + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) template<> constexpr GLenum textureTarget<3>() { #ifndef MAGNUM_TARGET_GLES2 return GL_TEXTURE_3D; @@ -51,6 +52,7 @@ namespace Implementation { return GL_TEXTURE_3D_OES; #endif } + #endif template VectorTypeFor maxTextureSize(); template<> MAGNUM_EXPORT Vector3i maxTextureSize<3>(); @@ -97,8 +99,9 @@ in shaders. @ref CubeMapTexture, @ref CubeMapTextureArray, @ref RectangleTexture, @ref BufferTexture, @ref MultisampleTexture @requires_gles30 Extension @es_extension{OES,texture_3D} for 3D textures in - OpenGL ES 2.0 -@requires_gl 1D textures are not available in OpenGL ES, only 2D and 3D ones. + OpenGL ES 2.0. +@requires_webgl20 3D textures are not available in WebGL 1.0. +@requires_gl 1D textures are not available in OpenGL ES or WebGL. */ template class Texture: public AbstractTexture { public: @@ -160,7 +163,7 @@ template class Texture: public AbstractTexture { * @brief Constructor * * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) is not supported, the texture is created on + * (part of OpenGL 4.5) is not available, the texture is created on * first use. * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_1D}, * @def_gl{TEXTURE_2D} or @def_gl{TEXTURE_3D}, eventually @@ -190,16 +193,17 @@ template class Texture: public AbstractTexture { * * Taken into account when generating mipmap using @ref generateMipmap() * and when considering texture completeness when using mipmap - * filtering. If on OpenGL ES or neither @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) nor @extension{EXT,direct_state_access} is - * available, the texture is bound before the operation (if not - * already). Initial value is `0`. + * filtering. If neither @extension{ARB,direct_state_access} (part of + * OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop + * extension is available, the texture is bound before the operation + * (if not already). Initial value is `0`. * @see @ref setMaxLevel(), @ref setMinificationFilter(), * @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_BASE_LEVEL} * @requires_gles30 Base level is always `0` in OpenGL ES 2.0. + * @requires_webgl20 Base level is always `0` in WebGL 1.0. */ Texture& setBaseLevel(Int level) { AbstractTexture::setBaseLevel(level); @@ -207,17 +211,18 @@ template class Texture: public AbstractTexture { } #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * @brief Set max mip level * @return Reference to self (for method chaining) * * Taken into account when generating mipmap using @ref generateMipmap() * and when considering texture completeness when using mipmap - * filtering. If on OpenGL ES or neither @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) nor @extension{EXT,direct_state_access} is - * available, the texture is bound before the operation (if not - * already). Initial value is `1000`, which is clamped to count of - * levels specified when using @ref setStorage(). + * filtering. If neither @extension{ARB,direct_state_access} (part of + * OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop + * extension is available, the texture is bound before the operation + * (if not already). Initial value is `1000`, which is clamped to count + * of levels specified when using @ref setStorage(). * @see @ref setBaseLevel(), @ref setMinificationFilter(), * @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, @@ -226,11 +231,13 @@ template class Texture: public AbstractTexture { * @requires_gles30 Extension @es_extension{APPLE,texture_max_level}, * otherwise the max level is always set to largest possible value * in OpenGL ES 2.0. + * @requires_webgl20 Always set to largest possible value in WebGL 1.0. */ Texture& setMaxLevel(Int level) { AbstractTexture::setMaxLevel(level); return *this; } + #endif /** * @brief Set minification filter @@ -241,10 +248,10 @@ template class Texture: public AbstractTexture { * @return Reference to self (for method chaining) * * Sets filter used when the object pixel size is smaller than the - * texture size. If on OpenGL ES or neither @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) nor @extension{EXT,direct_state_access} is - * available, the texture is bound before the operation (if not - * already). Initial value is {@ref Sampler::Filter::Nearest, + * texture size. If neither @extension{ARB,direct_state_access} (part + * of OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop + * extension is available, the texture is bound before the operation + * (if not already). Initial value is {@ref Sampler::Filter::Nearest, * @ref Sampler::Mipmap::Linear}. * @see @ref setMagnificationFilter(), @ref setBaseLevel(), * @ref setMaxLevel(), @fn_gl2{TextureParameter,TexParameter}, @@ -263,10 +270,10 @@ template class Texture: public AbstractTexture { * @return Reference to self (for method chaining) * * Sets filter used when the object pixel size is larger than largest - * texture size. If on OpenGL ES or neither @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) nor @extension{EXT,direct_state_access} is - * available, the texture is bound before the operation (if not - * already). Initial value is @ref Sampler::Filter::Linear. + * texture size. If neither @extension{ARB,direct_state_access} (part + * of OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop + * extension is available, the texture is bound before the operation + * (if not already). Initial value is @ref Sampler::Filter::Linear. * @see @ref setMinificationFilter(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -282,17 +289,19 @@ template class Texture: public AbstractTexture { * @brief Set minimum level-of-detail parameter * @return Reference to self (for method chaining) * - * Limits selection of highest resolution mipmap. If on OpenGL ES or - * neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor - * @extension{EXT,direct_state_access} is available, the texture is - * bound before the operation (if not already). Initial value is - * `-1000.0f`. + * Limits selection of highest resolution mipmap. If neither + * @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture is bound before the operation (if not already). Initial + * value is `-1000.0f`. * @see @ref setMaxLod(), @ref setLodBias(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_MIN_LOD} * @requires_gles30 Texture LOD parameters are not available in OpenGL * ES 2.0. + * @requires_webgl20 Texture LOD parameters are not available in WebGL + * 1.0. */ Texture& setMinLod(Float lod) { AbstractTexture::setMinLod(lod); @@ -303,17 +312,19 @@ template class Texture: public AbstractTexture { * @brief Set maximum level-of-detail parameter * @return Reference to self (for method chaining) * - * Limits selection of lowest resolution mipmap. If on OpenGL ES or - * neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor - * @extension{EXT,direct_state_access} is available, the texture is - * bound before the operation (if not already). Initial value is - * `1000.0f`. + * Limits selection of lowest resolution mipmap. If neither + * @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture is bound before the operation (if not already). Initial + * value is `1000.0f`. * @see @ref setMinLod(), @ref setLodBias(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_MAX_LOD} * @requires_gles30 Texture LOD parameters are not available in OpenGL * ES 2.0. + * @requires_webgl20 Texture LOD parameters are not available in WebGL + * 1.0. */ Texture& setMaxLod(Float lod) { AbstractTexture::setMaxLod(lod); @@ -337,7 +348,7 @@ template class Texture: public AbstractTexture { * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_LOD_BIAS} * @requires_gl Texture LOD bias can be specified only directly in - * fragment shader in OpenGL ES. + * fragment shader in OpenGL ES and WebGL. */ Texture& setLodBias(Float bias) { AbstractTexture::setLodBias(bias); @@ -351,10 +362,10 @@ template class Texture: public AbstractTexture { * @return Reference to self (for method chaining) * * Sets wrapping type for coordinates out of range @f$ [ 0.0, 1.0 ] @f$. - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). Initial - * value is @ref Sampler::Wrapping::Repeat. + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is + * available, the texture is bound before the operation (if not + * already). Initial value is @ref Sampler::Wrapping::Repeat. * @see @ref setBorderColor(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -366,25 +377,28 @@ template class Texture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @brief Set border color * @return Reference to self (for method chaining) * * Border color when wrapping is set to @ref Sampler::Wrapping::ClampToBorder. - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). Initial - * value is `{0.0f, 0.0f, 0.0f, 0.0f}`. + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} is available, the texture is + * bound before the operation (if not already). Initial value is + * `{0.0f, 0.0f, 0.0f, 0.0f}`. * @see @ref setWrapping(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_BORDER_COLOR} * @requires_es_extension Extension @es_extension{NV,texture_border_clamp} + * @requires_gles Border clamp is not available in WebGL. */ Texture& setBorderColor(const Color4& color) { AbstractTexture::setBorderColor(color); return *this; } + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -402,8 +416,8 @@ template class Texture: public AbstractTexture { * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_BORDER_COLOR} * @requires_gl30 Extension @extension{EXT,texture_integer} - * @requires_gl Border is available only for float textures in OpenGL - * ES. + * @requires_gl Border clamp is available only for float textures in + * OpenGL ES. Border clamp is not available in WebGL. */ Texture& setBorderColor(const Vector4ui& color) { AbstractTexture::setBorderColor(color); @@ -412,8 +426,8 @@ template class Texture: public AbstractTexture { /** @overload * @requires_gl30 Extension @extension{EXT,texture_integer} - * @requires_gl Border is available only for float textures in OpenGL - * ES. + * @requires_gl Border clamp is available only for float textures in + * OpenGL ES. Border clamp is not available in WebGL. */ Texture& setBorderColor(const Vector4i& color) { AbstractTexture::setBorderColor(color); @@ -428,10 +442,10 @@ template class Texture: public AbstractTexture { * Default value is `1.0f`, which means no anisotropy. Set to value * greater than `1.0f` for anisotropic filtering. If extension * @extension{EXT,texture_filter_anisotropic} (desktop or ES) is not - * available, this function does nothing. If on OpenGL ES or neither + * available, this function does nothing. If neither * @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor - * @extension{EXT,direct_state_access} is available, the texture is - * bound before the operation (if not already). + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture is bound before the operation (if not already). * @see @ref Sampler::maxMaxAnisotropy(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -442,15 +456,16 @@ template class Texture: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @brief Set sRGB decoding * @return Reference to self (for method chaining) * - * Disables or reenables decoding of sRGB values. If on OpenGL ES or - * neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor - * @extension{EXT,direct_state_access} is available, the texture is - * bound before the operation (if not already). Initial value is - * `true`. + * Disables or reenables decoding of sRGB values. If neither + * @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture is bound before the operation (if not already). Initial + * value is `true`. * @see @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -459,13 +474,15 @@ template class Texture: public AbstractTexture { * @requires_es_extension OpenGL ES 3.0 or extension * @es_extension{EXT,sRGB} and * @es_extension2{EXT,texture_sRGB_decode,texture_sRGB_decode} + * @requires_gles SRGB decode is not available in WebGL. */ Texture& setSRGBDecode(bool decode) { AbstractTexture::setSRGBDecode(decode); return *this; } + #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** * @brief Set component swizzle * @return Reference to self (for method chaining) @@ -476,10 +493,10 @@ template class Texture: public AbstractTexture { * @code * texture.setSwizzle<'b', 'g', 'r', '0'>(); * @endcode - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). Initial - * value is `rgba`. + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is + * available, the texture is bound before the operation (if not + * already). Initial value is `rgba`. * @see @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -489,6 +506,7 @@ template class Texture: public AbstractTexture { * separately in OpenGL ES) * @requires_gl33 Extension @extension{ARB,texture_swizzle} * @requires_gles30 Texture swizzle is not available in OpenGL ES 2.0. + * @requires_gles Texture swizzle is not available in WebGL. */ template Texture& setSwizzle() { AbstractTexture::setSwizzle(); @@ -496,20 +514,24 @@ template class Texture: public AbstractTexture { } #endif + #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** * @brief Set depth texture comparison mode * @return Reference to self (for method chaining) * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). Initial - * value is @ref Sampler::CompareMode::None. + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is + * available, the texture is bound before the operation (if not + * already). Initial value is @ref Sampler::CompareMode::None. * @note Depth textures can be only 1D or 2D. * @see @ref setCompareFunction(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_COMPARE_MODE} - * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} + * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} in + * OpenGL ES 2.0. + * @requires_webgl20 Depth texture comparison is not available in WebGL + * 1.0. */ Texture& setCompareMode(Sampler::CompareMode mode) { AbstractTexture::setCompareMode(mode); @@ -521,33 +543,37 @@ template class Texture: public AbstractTexture { * @return Reference to self (for method chaining) * * Comparison operator used when comparison mode is set to - * @ref Sampler::CompareMode::CompareRefToTexture. If on OpenGL ES or - * neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor - * @extension{EXT,direct_state_access} is available, the texture is - * bound before the operation (if not already). Initial value is - * @ref Sampler::CompareFunction::LessOrEqual. + * @ref Sampler::CompareMode::CompareRefToTexture. If neither + * @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture is bound before the operation (if not already). Initial + * value is @ref Sampler::CompareFunction::LessOrEqual. * @note Depth textures can be only 1D or 2D. * @see @ref setCompareMode(), @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexParameter} with @def_gl{TEXTURE_COMPARE_FUNC} - * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} + * @requires_gles30 Extension @es_extension{EXT,shadow_samplers} in + * OpenGL ES 2.0. + * @requires_webgl20 Depth texture comparison is not available in WebGL + * 1.0. */ Texture& setCompareFunction(Sampler::CompareFunction function) { AbstractTexture::setCompareFunction(function); return *this; } + #endif - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /** * @brief Set depth/stencil texture mode * @return Reference to self (for method chaining) * * Selects which component of packed depth/stencil texture is used for - * texturing. If on OpenGL ES or neither @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) nor @extension{EXT,direct_state_access} is - * available, the texture is bound before the operation (if not - * already). Initial value is @ref Sampler::DepthStencilMode::DepthComponent. + * texturing. If neither @extension{ARB,direct_state_access} (part of + * OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, + * the texture is bound before the operation (if not already). Initial + * value is @ref Sampler::DepthStencilMode::DepthComponent. * @note Depth textures can be only 1D or 2D. * @see @fn_gl2{TextureParameter,TexParameter}, * @fn_gl_extension{TextureParameter,EXT,direct_state_access}, @@ -556,6 +582,7 @@ template class Texture: public AbstractTexture { * @requires_gl43 Extension @extension{ARB,stencil_texturing} * @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0 * and older. + * @requires_gles Stencil texturing is not available in WebGL. */ Texture& setDepthStencilMode(Sampler::DepthStencilMode mode) { AbstractTexture::setDepthStencilMode(mode); @@ -573,8 +600,8 @@ template class Texture: public AbstractTexture { * After calling this function the texture is immutable and calling * @ref setStorage() or @ref setImage() is not allowed. * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) nor @extension{EXT,direct_state_access} is + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is * available, the texture is bound before the operation (if not * already). If neither @extension{ARB,texture_storage} (part of OpenGL * 4.2), OpenGL ES 3.0 nor @es_extension{EXT,texture_storage} in OpenGL @@ -599,10 +626,10 @@ template class Texture: public AbstractTexture { /** * @brief Image size in given mip level * - * The result is not cached in any way. If on OpenGL ES or neither + * The result is not cached in any way. If neither * @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor - * @extension{EXT,direct_state_access} is available, the texture is - * bound before the operation (if not already). + * @extension{EXT,direct_state_access} desktop extension is available, + * the texture is bound before the operation (if not already). * @see @ref image(), @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter}, * @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -610,6 +637,8 @@ template class Texture: public AbstractTexture { * @def_gl{TEXTURE_HEIGHT}, @def_gl{TEXTURE_DEPTH} * @requires_gles31 Texture image size queries are not available in * OpenGL ES 3.0 and older. + * @requires_gles Texture image size queries are not available in + * WebGL. */ VectorTypeFor imageSize(Int level) { return DataHelper::imageSize(*this, level); @@ -643,8 +672,8 @@ template class Texture: public AbstractTexture { * @fn_gl_extension{GetnTexImage,ARB,robustness}, * @fn_gl_extension{GetTextureImage,EXT,direct_state_access}, * eventually @fn_gl{GetTexImage} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void image(Int level, Image& image) { AbstractTexture::image(level, image); @@ -666,8 +695,8 @@ template class Texture: public AbstractTexture { * @param usage Buffer usage * * See @ref image(Int, Image&) for more information. - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. * @todo Make it more flexible (usable with * @extension{ARB,buffer_storage}, avoiding relocations...) */ @@ -694,8 +723,8 @@ template class Texture: public AbstractTexture { * given image. * @see @fn_gl{GetTextureSubImage} * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void subImage(Int level, const RangeTypeFor& range, Image& image) { AbstractTexture::subImage(level, range, image); @@ -720,8 +749,8 @@ template class Texture: public AbstractTexture { * See @ref subImage(Int, const RangeTypeFor&, Image&) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void subImage(Int level, const RangeTypeFor& range, BufferImage& image, BufferUsage usage) { AbstractTexture::subImage(level, range, image, usage); @@ -764,6 +793,8 @@ template class Texture: public AbstractTexture { /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ @@ -775,6 +806,8 @@ template class Texture: public AbstractTexture { /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ @@ -791,15 +824,10 @@ template class Texture: public AbstractTexture { * @ref Trade::ImageData of the same dimension count * @return Reference to self (for method chaining) * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). - * - * @attention In @ref MAGNUM_TARGET_WEBGL "WebGL" the @ref ColorType of - * data passed in @p image must match the original one specified - * in @ref setImage(). It means that you might not be able to use - * @ref setStorage() as it uses implicit @ref ColorType value. - * + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is + * available, the texture is bound before the operation (if not + * already). * @see @ref setStorage(), @fn_gl2{TextureSubImage1D,TexSubImage1D} / * @fn_gl2{TextureSubImage2D,TexSubImage2D} / @fn_gl2{TextureSubImage3D,TexSubImage3D}, * @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access} / @@ -807,6 +835,11 @@ template class Texture: public AbstractTexture { * @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexSubImage1D} / @fn_gl{TexSubImage2D} / @fn_gl{TexSubImage3D} + * @requires_gles In @ref MAGNUM_TARGET_WEBGL "WebGL" the @ref ColorType + * of data passed in @p image must match the original one + * specified in @ref setImage(). It means that you might not be + * able to use @ref setStorage() as it uses implicit @ref ColorType + * value. */ Texture& setSubImage(Int level, const VectorTypeFor& offset, const ImageReference& image) { DataHelper::setSubImage(*this, level, offset, image); @@ -817,6 +850,8 @@ template class Texture: public AbstractTexture { /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. */ Texture& setSubImage(Int level, const VectorTypeFor& offset, BufferImage& image) { DataHelper::setSubImage(*this, level, offset, image); @@ -826,6 +861,8 @@ template class Texture: public AbstractTexture { /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES * 2.0. + * @requires_webgl20 Pixel buffer objects are not available in WebGL + * 1.0. */ Texture& setSubImage(Int level, const VectorTypeFor& offset, BufferImage&& image) { return setSubImage(level, offset, image); @@ -836,9 +873,10 @@ template class Texture: public AbstractTexture { * @brief Generate mipmap * @return Reference to self (for method chaining) * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is + * available, the texture is bound before the operation (if not + * already). * @see @ref setMinificationFilter(), @fn_gl2{GenerateTextureMipmap,GenerateMipmap}, * @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access}, * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -891,7 +929,7 @@ template class Texture: public AbstractTexture { /** @brief One-dimensional texture -@requires_gl Only 2D and 3D textures are available in OpenGL ES. +@requires_gl Only 2D and 3D textures are available in OpenGL ES and WebGL. */ typedef Texture<1> Texture1D; #endif @@ -903,6 +941,7 @@ typedef Texture<2> Texture2D; @brief Three-dimensional texture @requires_gles30 Extension @es_extension{OES,texture_3D} in OpenGL ES 2.0 +@requires_webgl20 3D textures are not available in WebGL 1.0. */ typedef Texture<3> Texture3D; diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index be03adfdf..ae31bf074 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -89,7 +89,9 @@ documentation for more information about usage in shaders. @ref BufferTexture, @ref MultisampleTexture @requires_gl30 Extension @extension{EXT,texture_array} @requires_gles30 Array textures are not available in OpenGL ES 2.0. -@requires_gl 1D array textures are not available in OpenGL ES, only 2D ones. +@requires_webgl20 Array textures are not available in WebGL 1.0. +@requires_gl 1D array textures are not available in OpenGL ES or WebGL, only + 2D ones. @todo Fix this when @es_extension{NV,texture_array} is in ES2 extension headers */ template class TextureArray: public AbstractTexture { @@ -111,7 +113,7 @@ template class TextureArray: public AbstractTexture { * @brief Constructor * * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} - * (part of OpenGL 4.5) is not supported, the texture is created on + * (part of OpenGL 4.5) is not available, the texture is created on * first use. * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_1D_ARRAY} or * @def_gl{TEXTURE_2D_ARRAY}, eventually @fn_gl{GenTextures} @@ -191,7 +193,7 @@ template class TextureArray: public AbstractTexture { * * See @ref Texture::setLodBias() for more information. * @requires_gl Texture LOD bias can be specified only directly in - * fragment shader in OpenGL ES. + * fragment shader in OpenGL ES and WebGL. */ TextureArray& setLodBias(Float bias) { AbstractTexture::setLodBias(bias); @@ -210,6 +212,7 @@ template class TextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @copybrief Texture::setBorderColor(const Color4&) * @return Reference to self (for method chaining) @@ -217,11 +220,13 @@ template class TextureArray: public AbstractTexture { * See @ref Texture::setBorderColor(const Color4&) for more * information. * @requires_es_extension Extension @es_extension{NV,texture_border_clamp} + * @requires_gles Border clamp is not available in WebGL. */ TextureArray& setBorderColor(const Color4& color) { AbstractTexture::setBorderColor(color); return *this; } + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -231,8 +236,8 @@ template class TextureArray: public AbstractTexture { * See @ref Texture::setBorderColor(const Vector4ui&) for more * information. * @requires_gl30 Extension @extension{EXT,texture_integer} - * @requires_gl Border is available only for float textures in OpenGL - * ES. + * @requires_gl Border clamp is available only for float textures in + * OpenGL ES. Border clamp is not available in WebGL. */ TextureArray& setBorderColor(const Vector4ui& color) { AbstractTexture::setBorderColor(color); @@ -241,8 +246,8 @@ template class TextureArray: public AbstractTexture { /** @overload * @requires_gl30 Extension @extension{EXT,texture_integer} - * @requires_gl Border is available only for float textures in OpenGL - * ES. + * @requires_gl Border clamp is available only for float textures in + * OpenGL ES. Border clamp is not available in WebGL. */ TextureArray& setBorderColor(const Vector4i& color) { AbstractTexture::setBorderColor(color); @@ -261,6 +266,7 @@ template class TextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @copybrief Texture::setSRGBDecode() * @return Reference to self (for method chaining) @@ -268,6 +274,7 @@ template class TextureArray: public AbstractTexture { * See @ref Texture::setSRGBDecode() for more information. * @requires_extension Extension @extension{EXT,texture_sRGB_decode} * @requires_es_extension Extension @es_extension2{EXT,texture_sRGB_decode,texture_sRGB_decode} + * @requires_gles SRGB decode is not available in WebGL. */ TextureArray& setSRGBDecode(bool decode) { AbstractTexture::setSRGBDecode(decode); @@ -285,6 +292,7 @@ template class TextureArray: public AbstractTexture { AbstractTexture::setSwizzle(); return *this; } + #endif /** * @copybrief Texture::setCompareMode() @@ -308,6 +316,7 @@ template class TextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @copybrief Texture::setDepthStencilMode() * @return Reference to self (for method chaining) @@ -316,11 +325,13 @@ template class TextureArray: public AbstractTexture { * @requires_gl43 Extension @extension{ARB,stencil_texturing} * @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0 * and older. + * @requires_gles Stencil texturing is not available in WebGL. */ TextureArray& setDepthStencilMode(Sampler::DepthStencilMode mode) { AbstractTexture::setDepthStencilMode(mode); return *this; } + #endif /** * @copybrief Texture::setStorage() @@ -334,16 +345,20 @@ template class TextureArray: public AbstractTexture { return *this; } + #ifndef MAGNUM_TARGET_WEBGL /** * @copybrief Texture::imageSize() * * See @ref Texture::imageSize() for more information. * @requires_gles31 Texture image size queries are not available in * OpenGL ES 3.0 and older. + * @requires_gles Texture image size queries are not available in + * WebGL. */ VectorTypeFor imageSize(Int level) { return DataHelper::imageSize(*this, level); } + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -351,8 +366,8 @@ template class TextureArray: public AbstractTexture { * @return Reference to self (for method chaining) * * See @ref Texture::image(Int, Image&) for more information. - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void image(Int level, Image& image) { AbstractTexture::image(level, image); @@ -373,8 +388,8 @@ template class TextureArray: public AbstractTexture { * * See @ref Texture::image(Int, BufferImage&, BufferUsage) for more * information. - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void image(Int level, BufferImage& image, BufferUsage usage) { AbstractTexture::image(level, image, usage); @@ -395,8 +410,8 @@ template class TextureArray: public AbstractTexture { * See @ref Texture::subImage(Int, const RangeTypeFor&, Image&) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void subImage(Int level, const RangeTypeFor& range, Image& image) { AbstractTexture::subImage(level, range, image); @@ -417,8 +432,8 @@ template class TextureArray: public AbstractTexture { * See @ref Texture::subImage(Int, const RangeTypeFor&, BufferImage&, BufferUsage) * for more information. * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} - * @requires_gl Texture image queries are not available in OpenGL ES. - * See @ref Framebuffer::read() for possible workaround. + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. */ void subImage(Int level, const RangeTypeFor& range, BufferImage& image, BufferUsage usage) { AbstractTexture::subImage(level, range, image, usage); @@ -473,9 +488,10 @@ template class TextureArray: public AbstractTexture { * @ref Trade::ImageData of the same dimension count * @return Reference to self (for method chaining) * - * If on OpenGL ES or neither @extension{ARB,direct_state_access} (part - * of OpenGL 4.5) nor @extension{EXT,direct_state_access} is available, - * the texture is bound before the operation (if not already). + * If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) + * nor @extension{EXT,direct_state_access} desktop extension is + * available, the texture is bound before the operation (if not + * already). * @see @ref setStorage(), @fn_gl2{TextureSubImage2D,TexSubImage2D}/ * @fn_gl2{TextureSubImage3D,TexSubImage3D}, * @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}/ @@ -547,7 +563,7 @@ template class TextureArray: public AbstractTexture { @brief One-dimensional texture array @requires_gl30 Extension @extension{EXT,texture_array} -@requires_gl Only @ref Texture2DArray is available in OpenGL ES. +@requires_gl Only @ref Texture2DArray is available in OpenGL ES and WebGL. */ typedef TextureArray<1> Texture1DArray; #endif @@ -557,6 +573,7 @@ typedef TextureArray<1> Texture1DArray; @requires_gl30 Extension @extension{EXT,texture_array} @requires_gles30 Array textures are not available in OpenGL ES 2.0. +@requires_webgl20 Array textures are not available in WebGL 1.0. */ typedef TextureArray<2> Texture2DArray;