From 0955390ca84a2ed9b9adcd274e3ff16f5ab654e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 25 Mar 2014 17:46:21 +0100 Subject: [PATCH] Follow OpenGL terminology for texture binding units. Until now the textures were bound to layers, which was rather confusing, especially when binding layered textures to layers (gaah). Also the wording might have implied that each texture must be in some layer in order to make it usable in shader. This is no longer the case with (yet unimplemented) bindless texture, so another reason to remove the confusion. All occurences of texture layers were replaced texture binding units to follow OpenGL naming. It was mostly in the docs, except for already-deprecated *Layer enums in shaders, but they will be removed soon anyway. --- doc/portability.dox | 4 +- src/Magnum/AbstractShaderProgram.h | 23 +++++----- src/Magnum/AbstractTexture.cpp | 50 +++++++++++----------- src/Magnum/AbstractTexture.h | 38 ++++++++-------- src/Magnum/Implementation/TextureState.cpp | 10 ++--- src/Magnum/Implementation/TextureState.h | 4 +- src/Magnum/RectangleTexture.h | 26 +++++------ src/Magnum/Shaders/AbstractVector.h | 2 +- src/Magnum/Shaders/Flat.h | 3 +- src/Magnum/Shaders/Phong.h | 12 +++--- src/Magnum/Texture.h | 41 +++++++++--------- src/Magnum/TextureArray.h | 6 +-- src/Magnum/TextureTools/DistanceField.cpp | 6 +-- 13 files changed, 113 insertions(+), 112 deletions(-) diff --git a/doc/portability.dox b/doc/portability.dox index 880775cda..578d0fa46 100644 --- a/doc/portability.dox +++ b/doc/portability.dox @@ -161,8 +161,8 @@ if(!Context::instance()->isExtensionSupported%Texture setting functions in which you bind the textures - to particular layers using @ref *Texture::bind() and equivalents, for - example: + to particular texture units using @ref *Texture::bind() and equivalents, + for example: @code MyShader& setDiffuseTexture(Texture2D& texture) { texture.bind(0); @@ -219,10 +219,10 @@ Int normalMatrixUniform = uniformLocation("normalMatrix"); @ref Magnum::AbstractShaderProgram::uniformLocation() "uniformLocation()" instead. -@subsection AbstractShaderProgram-texture-layer Binding texture layer uniforms +@subsection AbstractShaderProgram-texture-units Specifying texture binding units -The preferred workflow is to specify texture layers directly in the shader -code, e.g.: +The preferred workflow is to specify texture binding unit directly in the +shader code, e.g.: @code // GLSL 4.20, or #extension GL_ARB_shading_language_420pack: enable @@ -230,11 +230,10 @@ layout(binding = 0) uniform sampler2D diffuseTexture; layout(binding = 1) uniform sampler2D specularTexture; @endcode -If you don't have the required extension (or if you want to change the layer -later), declare the uniforms without the `layout()` qualifier and set the -texture layer uniform using @ref setUniform(Int, const T&) "setUniform(Int, Int)". -Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES -1.0. +If you don't have the required extension, declare the uniforms without the +`layout()` qualifier and set the texture binding unit using +@ref setUniform(Int, const T&) "setUniform(Int, Int)". Note that additional +syntax changes may be needed for GLSL 1.20 and GLSL ES 1.0. @code uniform sampler2D diffuseTexture; uniform sampler2D specularTexture; @@ -246,9 +245,9 @@ setUniform(uniformLocation("specularTexture"), 1); @see @ref Shader::maxTextureImageUnits() @requires_gl42 %Extension @extension{ARB,shading_language_420pack} for explicit - texture layer binding instead of using + texture binding unit instead of using @ref Magnum::AbstractShaderProgram::setUniform(Int, const T&) "setUniform(Int, Int)". -@requires_gl Explicit texture layer binding is not supported in OpenGL ES. Use +@requires_gl Explicit texture binding unit is not supported in OpenGL ES. Use @ref Magnum::AbstractShaderProgram::setUniform(Int, const T&) "setUniform(Int, Int)" instead. diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 83eee7b62..26d668a75 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -116,33 +116,33 @@ AbstractTexture& AbstractTexture::setLabel(const std::string& label) { return *this; } -void AbstractTexture::bind(Int layer) { +void AbstractTexture::bind(Int textureUnit) { Implementation::TextureState* const textureState = Context::current()->state().texture; - /* If already bound in given layer, nothing to do */ - if(textureState->bindings[layer] == _id) return; + /* If already bound in given texture unit, nothing to do */ + if(textureState->bindings[textureUnit] == _id) return; - (this->*Context::current()->state().texture->bindImplementation)(layer); + (this->*Context::current()->state().texture->bindImplementation)(textureUnit); } -void AbstractTexture::bindImplementationDefault(GLint layer) { +void AbstractTexture::bindImplementationDefault(GLint textureUnit) { Implementation::TextureState* const textureState = Context::current()->state().texture; - /* Change to given layer, if not already there */ - if(textureState->currentLayer != layer) - glActiveTexture(GL_TEXTURE0 + (textureState->currentLayer = layer)); + /* Activate given texture unit, if not already active */ + if(textureState->currentTextureUnit != textureUnit) + glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = textureUnit)); - /* Bind the texture to the layer */ - glBindTexture(_target, (textureState->bindings[layer] = _id)); + /* Bind the texture to the unit */ + glBindTexture(_target, (textureState->bindings[textureUnit] = _id)); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::bindImplementationMulti(GLint layer) { - glBindTextures(layer, 1, &_id); +void AbstractTexture::bindImplementationMulti(GLint textureUnit) { + glBindTextures(textureUnit, 1, &_id); } -void AbstractTexture::bindImplementationDSA(GLint layer) { - glBindMultiTextureEXT(GL_TEXTURE0 + layer, _target, (Context::current()->state().texture->bindings[layer] = _id)); +void AbstractTexture::bindImplementationDSA(GLint textureUnit) { + glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, (Context::current()->state().texture->bindings[textureUnit] = _id)); } #endif @@ -187,24 +187,24 @@ void AbstractTexture::mipmapImplementationDSA() { void AbstractTexture::bindInternal() { /* Using glBindTextures() here is meaningless, because the non-DSA - functions need to have the texture bound in *currently active* layer, + functions need to have the texture bound in *currently active* unit, so we would need to call glActiveTexture() afterwards anyway. */ Implementation::TextureState* const textureState = Context::current()->state().texture; - /* If the texture is already bound in current layer, nothing to do */ - if(textureState->bindings[textureState->currentLayer] == _id) + /* If the texture is already bound in current unit, nothing to do */ + if(textureState->bindings[textureState->currentTextureUnit] == _id) return; - /* Set internal layer as active if not already */ - CORRADE_INTERNAL_ASSERT(textureState->maxLayers > 1); - const GLint internalLayer = textureState->maxLayers-1; - if(textureState->currentLayer != internalLayer) - glActiveTexture(GL_TEXTURE0 + (textureState->currentLayer = internalLayer)); + /* Set internal unit as active if not already */ + CORRADE_INTERNAL_ASSERT(textureState->maxTextureUnits > 1); + const GLint internalTextureUnit = textureState->maxTextureUnits-1; + if(textureState->currentTextureUnit != internalTextureUnit) + glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = internalTextureUnit)); - /* Bind the texture to internal layer, if not already */ - if(textureState->bindings[internalLayer] != _id) - glBindTexture(_target, (textureState->bindings[internalLayer] = _id)); + /* Bind the texture to internal unit, if not already */ + if(textureState->bindings[internalTextureUnit] != _id) + glBindTexture(_target, (textureState->bindings[internalTextureUnit] = _id)); } ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) { diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 670edbed8..263094e53 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -51,17 +51,18 @@ documentation for details. @section AbstractTexture-performance-optimization Performance optimizations and security -The engine tracks currently bound textures in all available layers to avoid -unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. %Texture -configuration functions use dedicated highest available texture layer to not -affect active bindings in user layers. %Texture limits and +The engine tracks currently bound textures in all available texture units to +avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. +%Texture configuration functions use dedicated highest available texture unit +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 extension @extension{ARB,multi_bind} is available, @ref bind() uses @fn_gl{BindTextures} to avoid unnecessary calls to @fn_gl{ActiveTexture}. Otherwise, if extension @extension{EXT,direct_state_access} is available, -@ref bind() uses the DSA function. +@ref bind() uses @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} +function. In addition, if extension @extension{EXT,direct_state_access} is available, also all texture configuration and data updating functions use DSA functions @@ -76,7 +77,7 @@ there isn't any function combining both features. 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 -dedicated layers, not occupied by other textures. First configure the texture +dedicated units, not occupied by other textures. First configure the texture and *then* set the data, so OpenGL can optimize them to match the settings. To avoid redundant consistency checks and memory reallocations when updating texture data, set texture storage at once using @ref Texture::setStorage() "setStorage()" @@ -215,20 +216,19 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { GLuint id() const { return _id; } /** - * @brief Bind texture for rendering + * @brief Bind texture to given texture unit * - * Sets current texture as active in given layer. Note that only one - * texture can be bound to given layer. If @extension{ARB,multi_bind} - * (part of OpenGL 4.4) or @extension{EXT,direct_state_access} is not - * available, the layer is made active before binding the texture. + * If @extension{ARB,multi_bind} (part of OpenGL 4.4) or + * @extension{EXT,direct_state_access} is not 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. - * @see @ref maxLayers(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture}, - * @fn_gl{BindTextures} or - * @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} + * @see @ref Shader::maxCombinedTextureImageUnits(), + * @fn_gl{ActiveTexture}, @fn_gl{BindTexture}, @fn_gl{BindTextures} + * or @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} */ - void bind(Int layer); + void bind(Int textureUnit); #ifdef DOXYGEN_GENERATING_OUTPUT private: @@ -239,7 +239,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { explicit AbstractTexture(GLenum target); - /* Unlike bind() this also sets the binding layer as active */ + /* Unlike bind() this also sets the texture binding unit as active */ void MAGNUM_LOCAL bindInternal(); void setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap); @@ -257,10 +257,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { GLenum _target; private: - void MAGNUM_LOCAL bindImplementationDefault(GLint layer); + void MAGNUM_LOCAL bindImplementationDefault(GLint textureUnit); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL bindImplementationMulti(GLint layer); - void MAGNUM_LOCAL bindImplementationDSA(GLint layer); + void MAGNUM_LOCAL bindImplementationMulti(GLint textureUnit); + void MAGNUM_LOCAL bindImplementationDSA(GLint textureUnit); #endif void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, GLint value); diff --git a/src/Magnum/Implementation/TextureState.cpp b/src/Magnum/Implementation/TextureState.cpp index 845ade148..536f6a7b9 100644 --- a/src/Magnum/Implementation/TextureState.cpp +++ b/src/Magnum/Implementation/TextureState.cpp @@ -36,7 +36,7 @@ namespace Magnum { namespace Implementation { -TextureState::TextureState(Context& context, std::vector& extensions): maxLayers(0), maxMaxAnisotropy(0.0f), currentLayer(0) +TextureState::TextureState(Context& context, std::vector& extensions): maxTextureUnits(0), maxMaxAnisotropy(0.0f), currentTextureUnit(0) #ifndef MAGNUM_TARGET_GLES , maxColorSamples(0), maxDepthSamples(0), maxIntegerSamples(0), bufferOffsetAlignment(0) #endif @@ -172,10 +172,10 @@ TextureState::TextureState(Context& context, std::vector& extension setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationExt; } else setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationNoOp; - /* Resize bindings array to hold all possible layers */ - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxLayers); - CORRADE_INTERNAL_ASSERT(maxLayers > 0); - bindings.resize(maxLayers); + /* Resize bindings array to hold all possible texture units */ + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + CORRADE_INTERNAL_ASSERT(maxTextureUnits > 0); + bindings.resize(maxTextureUnits); } TextureState::~TextureState() = default; diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index 3b766becb..f6dec2d7c 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -68,9 +68,9 @@ struct TextureState { void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); #endif - GLint maxLayers; + GLint maxTextureUnits; GLfloat maxMaxAnisotropy; - GLint currentLayer; + GLint currentTextureUnit; #ifndef MAGNUM_TARGET_GLES GLint maxColorSamples, maxDepthSamples, diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index 2d8c76c6c..034e44dd9 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -86,8 +86,8 @@ class RectangleTexture: public AbstractTexture { * * Sets filter used when the object pixel size is smaller than the * texture size. If @extension{EXT,direct_state_access} is not - * available, the texture is bound to some layer before the operation. - * Initial value is @ref Sampler::Filter::Linear. + * available, the texture is bound to some texture unit before the + * operation. Initial value is @ref Sampler::Filter::Linear. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_MIN_FILTER} @@ -109,7 +109,7 @@ class RectangleTexture: public AbstractTexture { * * The result is not cached in any way. If * @extension{EXT,direct_state_access} is not available, the texture - * is bound to some layer before the operation. + * is bound to some texture unit before the operation. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{GetTexLevelParameter} or @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_WIDTH} and @def_gl{TEXTURE_HEIGHT} @@ -124,9 +124,9 @@ class RectangleTexture: public AbstractTexture { * @return Reference to self (for method chaining) * * Sets wrapping type for coordinates out of (0, textureSizeInGivenDirection-1) - * range for rectangle textures. If @extension{EXT,direct_state_access} - * is not available, the texture is bound to some layer before the - * operation. Initial value is @ref Sampler::Wrapping::ClampToEdge. + * range. If @extension{EXT,direct_state_access} is not available, the + * texture is bound to some texture unit before the operation. Initial + * value is @ref Sampler::Wrapping::ClampToEdge. * @attention Only @ref Sampler::Wrapping::ClampToEdge and * @ref Sampler::Wrapping::ClampToBorder is supported on this * texture type. @@ -165,10 +165,10 @@ class RectangleTexture: public AbstractTexture { * allowed. * * If @extension{EXT,direct_state_access} is not available, the texture - * is bound to some layer before the operation. If @extension{ARB,texture_storage} - * (part of OpenGL 4.2), OpenGL ES 3.0 or @es_extension{EXT,texture_storage} - * in OpenGL ES 2.0 is not available, the feature is emulated with - * @ref setImage() call. + * is bound to some texture unit before the operation. If + * @extension{ARB,texture_storage} (part of OpenGL 4.2), OpenGL ES 3.0 + * or @es_extension{EXT,texture_storage} in OpenGL ES 2.0 is not + * available, the feature is emulated with @ref setImage() call. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexStorage2D} * or @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}, * eventually @fn_gl{TexImage2D} or @@ -189,7 +189,7 @@ class RectangleTexture: public AbstractTexture { * @ref imageSize(). * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. If + * texture is bound to some texture unit before the operation. If * @extension{ARB,robustness} is available, the operation is protected * from buffer overflow. However, if both @extension{EXT,direct_state_access} * and @extension{ARB,robustness} are available, the DSA version is @@ -230,7 +230,7 @@ class RectangleTexture: public AbstractTexture { * use @ref setStorage() and @ref setSubImage() instead. * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. + * texture is bound to some texture unit before the operation. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexImage2D} * or @fn_gl_extension{TextureImage2D,EXT,direct_state_access} */ @@ -260,7 +260,7 @@ class RectangleTexture: public AbstractTexture { * @return Reference to self (for method chaining) * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. + * texture is bound to some texture unit before the operation. * @see @ref setStorage(), @ref setImage(), @fn_gl{ActiveTexture}, * @fn_gl{BindTexture} and @fn_gl{TexSubImage2D} or * @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access} diff --git a/src/Magnum/Shaders/AbstractVector.h b/src/Magnum/Shaders/AbstractVector.h index 720de0714..4c1fc5399 100644 --- a/src/Magnum/Shaders/AbstractVector.h +++ b/src/Magnum/Shaders/AbstractVector.h @@ -49,7 +49,7 @@ template class AbstractVector: public AbstractShaderProg #ifdef MAGNUM_BUILD_DEPRECATED enum: Int { /** - * Layer for vector texture + * Vector texture binding unit * @deprecated Use @ref Magnum::Shaders::AbstractVector::setVectorTexture() "setVectorTexture()" instead. */ VectorTextureLayer = 16 diff --git a/src/Magnum/Shaders/Flat.h b/src/Magnum/Shaders/Flat.h index e64afdd2a..f4cdde677 100644 --- a/src/Magnum/Shaders/Flat.h +++ b/src/Magnum/Shaders/Flat.h @@ -74,7 +74,8 @@ template class MAGNUM_SHADERS_EXPORT Flat: public Abstra #ifdef MAGNUM_BUILD_DEPRECATED enum: Int { /** - * Layer for color texture. Used only if @ref Flag::Textured is set. + * Color texture binding unit. Used only if @ref Flag::Textured is + * set. * @deprecated use @ref Magnum::Shaders::Flat::setTexture() "setTexture()" instead. */ TextureLayer = 0 diff --git a/src/Magnum/Shaders/Phong.h b/src/Magnum/Shaders/Phong.h index f07967cfc..e203f98cc 100644 --- a/src/Magnum/Shaders/Phong.h +++ b/src/Magnum/Shaders/Phong.h @@ -65,24 +65,24 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { #ifdef MAGNUM_BUILD_DEPRECATED enum: Int { /** - * Layer for ambient texture. Used only if @ref Flag::AmbientTexture - * is set. + * Ambient texture binding unit. Used only if + * @ref Flag::AmbientTexture is set. * @deprecated Use @ref Magnum::Shaders::Phong::setAmbientTexture() "setAmbientTexture()" * instead. */ AmbientTextureLayer = 0, /** - * Layer for diffuse texture. Used only if @ref Flag::DiffuseTexture - * is set. + * Diffuse texture binding unit. Used only if + * @ref Flag::DiffuseTexture is set. * @deprecated Use @ref Magnum::Shaders::Phong::setDiffuseTexture() "setDiffuseTexture()" * instead. */ DiffuseTextureLayer = 1, /** - * Layer for specular texture. Used only if @ref Flag::SpecularTexture - * is set. + * Specular texture binding unit. Used only if + * @ref Flag::SpecularTexture is set. * @deprecated Use @ref Magnum::Shaders::Phong::setSpecularTexture() "setSpecularTexture()" * instead. */ diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 00e726294..6edcefa75 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -173,7 +173,7 @@ template class Texture: public AbstractTexture { * * The result is not cached in any way. If * @extension{EXT,direct_state_access} is not available, the texture - * is bound to some layer before the operation. + * is bound to some texture unit before the operation. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{GetTexLevelParameter} or @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_WIDTH}, @def_gl{TEXTURE_HEIGHT} or @def_gl{TEXTURE_DEPTH}. @@ -194,8 +194,9 @@ template class Texture: public AbstractTexture { * * Sets filter used when the object pixel size is smaller than the * texture size. If @extension{EXT,direct_state_access} is not - * available, the texture is bound to some layer before the operation. - * Initial value is (@ref Sampler::Filter::Nearest, @ref Sampler::Mipmap::Linear). + * available, the texture is bound to some texture unit before the + * operation. Initial value is {@ref Sampler::Filter::Nearest, + * @ref Sampler::Mipmap::Linear}. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_MIN_FILTER} @@ -212,8 +213,8 @@ template class Texture: public AbstractTexture { * * Sets filter used when the object pixel size is larger than largest * texture size. If @extension{EXT,direct_state_access} is not - * available, the texture is bound to some layer before the operation. - * Initial value is @ref Sampler::Filter::Linear. + * available, the texture is bound to some texture unit before the + * operation. Initial value is @ref Sampler::Filter::Linear. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_MAG_FILTER} @@ -228,11 +229,10 @@ template class Texture: public AbstractTexture { * @param wrapping Wrapping type for all texture dimensions * @return Reference to self (for method chaining) * - * Sets wrapping type for coordinates out of range (0, 1) for normal - * textures and (0, textureSizeInGivenDirection-1) for rectangle - * textures. If @extension{EXT,direct_state_access} is not available, - * the texture is bound to some layer before the operation. Initial - * value is @ref Sampler::Wrapping::Repeat. + * Sets wrapping type for coordinates out of range (0.0f, 1.0f). If + * @extension{EXT,direct_state_access} is not available, the texture is + * bound to some texture unit before the operation. Initial value is + * @ref Sampler::Wrapping::Repeat. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * with @def_gl{TEXTURE_WRAP_S}, @def_gl{TEXTURE_WRAP_T}, @@ -249,7 +249,7 @@ template class Texture: public AbstractTexture { * * Border color when wrapping is set to @ref Sampler::Wrapping::ClampToBorder. * If @extension{EXT,direct_state_access} is not available, the texture - * is bound to some layer before the operation. Initial value is + * is bound to some texture unit before the operation. Initial value is * `{0.0f, 0.0f, 0.0f, 0.0f}`. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access} @@ -270,7 +270,7 @@ template class Texture: public AbstractTexture { * @extension{EXT,texture_filter_anisotropic} (desktop or ES) is not * available, this function does nothing. If * @extension{EXT,direct_state_access} is not available, the texture is - * bound to some layer before the operation. + * bound to some texture unit before the operation. * @see @ref Sampler::maxMaxAnisotropy(), @fn_gl{ActiveTexture}, * @fn_gl{BindTexture} and @fn_gl{TexParameter} or * @fn_gl_extension{TextureParameter,EXT,direct_state_access} with @@ -295,10 +295,11 @@ template class Texture: public AbstractTexture { * allowed. * * If @extension{EXT,direct_state_access} is not available, the texture - * is bound to some layer before the operation. If @extension{ARB,texture_storage} - * (part of OpenGL 4.2), OpenGL ES 3.0 or @es_extension{EXT,texture_storage} - * in OpenGL ES 2.0 is not available, the feature is emulated with - * sequence of @ref setImage() calls. + * is bound to some texture unit before the operation. If + * @extension{ARB,texture_storage} (part of OpenGL 4.2), OpenGL ES 3.0 + * or @es_extension{EXT,texture_storage} in OpenGL ES 2.0 is not + * available, the feature is emulated with sequence of @ref setImage() + * calls. * @todo allow the user to specify ColorType explicitly to avoid * issues in WebGL (see setSubImage()) * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @@ -327,7 +328,7 @@ template class Texture: public AbstractTexture { * @ref imageSize(). * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. If + * texture is bound to some texture unit before the operation. If * @extension{ARB,robustness} is available, the operation is protected * from buffer overflow. However, if both @extension{EXT,direct_state_access} * and @extension{ARB,robustness} are available, the DSA version is @@ -371,7 +372,7 @@ template class Texture: public AbstractTexture { * @ref setStorage() and @ref setSubImage() instead. * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. + * texture is bound to some texture unit before the operation. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexImage1D}/@fn_gl{TexImage2D}/@fn_gl{TexImage3D} or * @fn_gl_extension{TextureImage1D,EXT,direct_state_access}/ @@ -405,7 +406,7 @@ template class Texture: public AbstractTexture { * @return Reference to self (for method chaining) * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. + * texture is bound to some texture unit before the operation. * * @attention In @ref MAGNUM_TARGET_WEBGL "WebGL" the @ref ColorType of * data passed in @p image must match the original one specified @@ -442,7 +443,7 @@ template class Texture: public AbstractTexture { * @return Reference to self (for method chaining) * * If @extension{EXT,direct_state_access} is not available, the texture - * is bound to some layer before the operation. + * is bound to some texture unit before the operation. * @see setMinificationFilter(), @fn_gl{ActiveTexture}, * @fn_gl{BindTexture} and @fn_gl{GenerateMipmap} or * @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access} diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 412bf6503..578fcb6a2 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -158,7 +158,7 @@ template class TextureArray: public AbstractTexture { * allowed. * * If @extension{EXT,direct_state_access} is not available, the texture - * is bound to some layer before the operation. If + * is bound to some texture unit before the operation. If * @extension{ARB,texture_storage} (part of OpenGL 4.2) or OpenGL ES * 3.0 is not available, the feature is emulated with sequence of * @ref setImage() calls. @@ -200,7 +200,7 @@ template class TextureArray: public AbstractTexture { * @ref setStorage() and @ref setSubImage() instead. * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. + * texture is bound to some texture unit before the operation. * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @fn_gl{TexImage2D}/@fn_gl{TexImage3D} or * @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/ @@ -233,7 +233,7 @@ template class TextureArray: public AbstractTexture { * @return Reference to self (for method chaining) * * If @extension{EXT,direct_state_access} is not available, the - * texture is bound to some layer before the operation. + * texture is bound to some texture unit before the operation. * @see @ref setStorage(), @ref setImage(), @fn_gl{ActiveTexture}, * @fn_gl{BindTexture} and @fn_gl{TexSubImage2D}/@fn_gl{TexSubImage3D} * or @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}/ diff --git a/src/Magnum/TextureTools/DistanceField.cpp b/src/Magnum/TextureTools/DistanceField.cpp index a68959db2..ccb2aefd6 100644 --- a/src/Magnum/TextureTools/DistanceField.cpp +++ b/src/Magnum/TextureTools/DistanceField.cpp @@ -63,12 +63,12 @@ class DistanceFieldShader: public AbstractShaderProgram { } DistanceFieldShader& setTexture(Texture2D& texture) { - texture.bind(TextureLayer); + texture.bind(TextureUnit); return *this; } private: - enum: Int { TextureLayer = 8 }; + enum: Int { TextureUnit = 8 }; Int radiusUniform, scalingUniform, @@ -130,7 +130,7 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) if(!Context::current()->isExtensionSupported()) #endif { - setUniform(uniformLocation("textureData"), TextureLayer); + setUniform(uniformLocation("textureData"), TextureUnit); } }