Browse Source

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.
pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
0955390ca8
  1. 4
      doc/portability.dox
  2. 23
      src/Magnum/AbstractShaderProgram.h
  3. 50
      src/Magnum/AbstractTexture.cpp
  4. 38
      src/Magnum/AbstractTexture.h
  5. 10
      src/Magnum/Implementation/TextureState.cpp
  6. 4
      src/Magnum/Implementation/TextureState.h
  7. 26
      src/Magnum/RectangleTexture.h
  8. 2
      src/Magnum/Shaders/AbstractVector.h
  9. 3
      src/Magnum/Shaders/Flat.h
  10. 12
      src/Magnum/Shaders/Phong.h
  11. 41
      src/Magnum/Texture.h
  12. 6
      src/Magnum/TextureArray.h
  13. 6
      src/Magnum/TextureTools/DistanceField.cpp

4
doc/portability.dox

@ -161,8 +161,8 @@ if(!Context::instance()->isExtensionSupported<Extensions::GL::ARB::explicit_attr
@endcode @endcode
See also @ref AbstractShaderProgram class documentation for information about See also @ref AbstractShaderProgram class documentation for information about
specifying attribute location, uniform location and texture layer in various specifying attribute location, uniform location and texture binding unit in
OpenGL versions. various OpenGL versions.
All shaders in @ref Shaders namespace support desktop OpenGL starting from All shaders in @ref Shaders namespace support desktop OpenGL starting from
version 2.1 and also OpenGL ES 2.0 and 3.0. Feel free to look into their version 2.1 and also OpenGL ES 2.0 and 3.0. Feel free to look into their

23
src/Magnum/AbstractShaderProgram.h

@ -103,8 +103,8 @@ MyShader& setNormalMatrix(const Matrix3x3& matrix) {
} }
@endcode @endcode
- <strong>%Texture setting functions</strong> in which you bind the textures - <strong>%Texture setting functions</strong> in which you bind the textures
to particular layers using @ref *Texture::bind() and equivalents, for to particular texture units using @ref *Texture::bind() and equivalents,
example: for example:
@code @code
MyShader& setDiffuseTexture(Texture2D& texture) { MyShader& setDiffuseTexture(Texture2D& texture) {
texture.bind(0); texture.bind(0);
@ -219,10 +219,10 @@ Int normalMatrixUniform = uniformLocation("normalMatrix");
@ref Magnum::AbstractShaderProgram::uniformLocation() "uniformLocation()" @ref Magnum::AbstractShaderProgram::uniformLocation() "uniformLocation()"
instead. 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 The preferred workflow is to specify texture binding unit directly in the
code, e.g.: shader code, e.g.:
@code @code
// GLSL 4.20, or // GLSL 4.20, or
#extension GL_ARB_shading_language_420pack: enable #extension GL_ARB_shading_language_420pack: enable
@ -230,11 +230,10 @@ layout(binding = 0) uniform sampler2D diffuseTexture;
layout(binding = 1) uniform sampler2D specularTexture; layout(binding = 1) uniform sampler2D specularTexture;
@endcode @endcode
If you don't have the required extension (or if you want to change the layer If you don't have the required extension, declare the uniforms without the
later), declare the uniforms without the `layout()` qualifier and set the `layout()` qualifier and set the texture binding unit using
texture layer uniform using @ref setUniform(Int, const T&) "setUniform(Int, Int)". @ref setUniform(Int, const T&) "setUniform(Int, Int)". Note that additional
Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES syntax changes may be needed for GLSL 1.20 and GLSL ES 1.0.
1.0.
@code @code
uniform sampler2D diffuseTexture; uniform sampler2D diffuseTexture;
uniform sampler2D specularTexture; uniform sampler2D specularTexture;
@ -246,9 +245,9 @@ setUniform(uniformLocation("specularTexture"), 1);
@see @ref Shader::maxTextureImageUnits() @see @ref Shader::maxTextureImageUnits()
@requires_gl42 %Extension @extension{ARB,shading_language_420pack} for explicit @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)". @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)" @ref Magnum::AbstractShaderProgram::setUniform(Int, const T&) "setUniform(Int, Int)"
instead. instead.

50
src/Magnum/AbstractTexture.cpp

@ -116,33 +116,33 @@ AbstractTexture& AbstractTexture::setLabel(const std::string& label) {
return *this; return *this;
} }
void AbstractTexture::bind(Int layer) { void AbstractTexture::bind(Int textureUnit) {
Implementation::TextureState* const textureState = Context::current()->state().texture; Implementation::TextureState* const textureState = Context::current()->state().texture;
/* If already bound in given layer, nothing to do */ /* If already bound in given texture unit, nothing to do */
if(textureState->bindings[layer] == _id) return; 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; Implementation::TextureState* const textureState = Context::current()->state().texture;
/* Change to given layer, if not already there */ /* Activate given texture unit, if not already active */
if(textureState->currentLayer != layer) if(textureState->currentTextureUnit != textureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentLayer = layer)); glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = textureUnit));
/* Bind the texture to the layer */ /* Bind the texture to the unit */
glBindTexture(_target, (textureState->bindings[layer] = _id)); glBindTexture(_target, (textureState->bindings[textureUnit] = _id));
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::bindImplementationMulti(GLint layer) { void AbstractTexture::bindImplementationMulti(GLint textureUnit) {
glBindTextures(layer, 1, &_id); glBindTextures(textureUnit, 1, &_id);
} }
void AbstractTexture::bindImplementationDSA(GLint layer) { void AbstractTexture::bindImplementationDSA(GLint textureUnit) {
glBindMultiTextureEXT(GL_TEXTURE0 + layer, _target, (Context::current()->state().texture->bindings[layer] = _id)); glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, (Context::current()->state().texture->bindings[textureUnit] = _id));
} }
#endif #endif
@ -187,24 +187,24 @@ void AbstractTexture::mipmapImplementationDSA() {
void AbstractTexture::bindInternal() { void AbstractTexture::bindInternal() {
/* Using glBindTextures() here is meaningless, because the non-DSA /* 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. */ so we would need to call glActiveTexture() afterwards anyway. */
Implementation::TextureState* const textureState = Context::current()->state().texture; Implementation::TextureState* const textureState = Context::current()->state().texture;
/* If the texture is already bound in current layer, nothing to do */ /* If the texture is already bound in current unit, nothing to do */
if(textureState->bindings[textureState->currentLayer] == _id) if(textureState->bindings[textureState->currentTextureUnit] == _id)
return; return;
/* Set internal layer as active if not already */ /* Set internal unit as active if not already */
CORRADE_INTERNAL_ASSERT(textureState->maxLayers > 1); CORRADE_INTERNAL_ASSERT(textureState->maxTextureUnits > 1);
const GLint internalLayer = textureState->maxLayers-1; const GLint internalTextureUnit = textureState->maxTextureUnits-1;
if(textureState->currentLayer != internalLayer) if(textureState->currentTextureUnit != internalTextureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentLayer = internalLayer)); glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = internalTextureUnit));
/* Bind the texture to internal layer, if not already */ /* Bind the texture to internal unit, if not already */
if(textureState->bindings[internalLayer] != _id) if(textureState->bindings[internalTextureUnit] != _id)
glBindTexture(_target, (textureState->bindings[internalLayer] = _id)); glBindTexture(_target, (textureState->bindings[internalTextureUnit] = _id));
} }
ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) { ColorFormat AbstractTexture::imageFormatForInternalFormat(const TextureFormat internalFormat) {

38
src/Magnum/AbstractTexture.h

@ -51,17 +51,18 @@ documentation for details.
@section AbstractTexture-performance-optimization Performance optimizations and security @section AbstractTexture-performance-optimization Performance optimizations and security
The engine tracks currently bound textures in all available layers to avoid The engine tracks currently bound textures in all available texture units to
unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. %Texture avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}.
configuration functions use dedicated highest available texture layer to not %Texture configuration functions use dedicated highest available texture unit
affect active bindings in user layers. %Texture limits and to not affect active bindings in user units. %Texture limits and
implementation-defined values (such as @ref maxColorSamples()) are cached, so implementation-defined values (such as @ref maxColorSamples()) are cached, so
repeated queries don't result in repeated @fn_gl{Get} calls. repeated queries don't result in repeated @fn_gl{Get} calls.
If extension @extension{ARB,multi_bind} is available, @ref bind() uses If extension @extension{ARB,multi_bind} is available, @ref bind() uses
@fn_gl{BindTextures} to avoid unnecessary calls to @fn_gl{ActiveTexture}. @fn_gl{BindTextures} to avoid unnecessary calls to @fn_gl{ActiveTexture}.
Otherwise, if extension @extension{EXT,direct_state_access} is available, 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, In addition, if extension @extension{EXT,direct_state_access} is available,
also all texture configuration and data updating functions use DSA functions 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 -- 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 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 and *then* set the data, so OpenGL can optimize them to match the settings. To
avoid redundant consistency checks and memory reallocations when updating avoid redundant consistency checks and memory reallocations when updating
texture data, set texture storage at once using @ref Texture::setStorage() "setStorage()" 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; } 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 * If @extension{ARB,multi_bind} (part of OpenGL 4.4) or
* texture can be bound to given layer. If @extension{ARB,multi_bind} * @extension{EXT,direct_state_access} is not available, the texture
* (part of OpenGL 4.4) or @extension{EXT,direct_state_access} is not * unit is made active before binding the texture.
* available, the layer is made active before binding the texture.
* @note This function is meant to be used only internally from * @note This function is meant to be used only internally from
* @ref AbstractShaderProgram subclasses. See its documentation * @ref AbstractShaderProgram subclasses. See its documentation
* for more information. * for more information.
* @see @ref maxLayers(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture}, * @see @ref Shader::maxCombinedTextureImageUnits(),
* @fn_gl{BindTextures} or * @fn_gl{ActiveTexture}, @fn_gl{BindTexture}, @fn_gl{BindTextures}
* @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} * or @fn_gl_extension{BindMultiTexture,EXT,direct_state_access}
*/ */
void bind(Int layer); void bind(Int textureUnit);
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
private: private:
@ -239,7 +239,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
explicit AbstractTexture(GLenum target); 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 MAGNUM_LOCAL bindInternal();
void setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap); void setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap);
@ -257,10 +257,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
GLenum _target; GLenum _target;
private: private:
void MAGNUM_LOCAL bindImplementationDefault(GLint layer); void MAGNUM_LOCAL bindImplementationDefault(GLint textureUnit);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL bindImplementationMulti(GLint layer); void MAGNUM_LOCAL bindImplementationMulti(GLint textureUnit);
void MAGNUM_LOCAL bindImplementationDSA(GLint layer); void MAGNUM_LOCAL bindImplementationDSA(GLint textureUnit);
#endif #endif
void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, GLint value); void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, GLint value);

10
src/Magnum/Implementation/TextureState.cpp

@ -36,7 +36,7 @@
namespace Magnum { namespace Implementation { namespace Magnum { namespace Implementation {
TextureState::TextureState(Context& context, std::vector<std::string>& extensions): maxLayers(0), maxMaxAnisotropy(0.0f), currentLayer(0) TextureState::TextureState(Context& context, std::vector<std::string>& extensions): maxTextureUnits(0), maxMaxAnisotropy(0.0f), currentTextureUnit(0)
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
, maxColorSamples(0), maxDepthSamples(0), maxIntegerSamples(0), bufferOffsetAlignment(0) , maxColorSamples(0), maxDepthSamples(0), maxIntegerSamples(0), bufferOffsetAlignment(0)
#endif #endif
@ -172,10 +172,10 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationExt; setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationExt;
} else setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationNoOp; } else setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationNoOp;
/* Resize bindings array to hold all possible layers */ /* Resize bindings array to hold all possible texture units */
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxLayers); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
CORRADE_INTERNAL_ASSERT(maxLayers > 0); CORRADE_INTERNAL_ASSERT(maxTextureUnits > 0);
bindings.resize(maxLayers); bindings.resize(maxTextureUnits);
} }
TextureState::~TextureState() = default; TextureState::~TextureState() = default;

4
src/Magnum/Implementation/TextureState.h

@ -68,9 +68,9 @@ struct TextureState {
void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr);
#endif #endif
GLint maxLayers; GLint maxTextureUnits;
GLfloat maxMaxAnisotropy; GLfloat maxMaxAnisotropy;
GLint currentLayer; GLint currentTextureUnit;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
GLint maxColorSamples, GLint maxColorSamples,
maxDepthSamples, maxDepthSamples,

26
src/Magnum/RectangleTexture.h

@ -86,8 +86,8 @@ class RectangleTexture: public AbstractTexture {
* *
* Sets filter used when the object pixel size is smaller than the * Sets filter used when the object pixel size is smaller than the
* texture size. If @extension{EXT,direct_state_access} is not * texture size. If @extension{EXT,direct_state_access} is not
* available, the texture is bound to some layer before the operation. * available, the texture is bound to some texture unit before the
* Initial value is @ref Sampler::Filter::Linear. * operation. Initial value is @ref Sampler::Filter::Linear.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_MIN_FILTER} * with @def_gl{TEXTURE_MIN_FILTER}
@ -109,7 +109,7 @@ class RectangleTexture: public AbstractTexture {
* *
* The result is not cached in any way. If * The result is not cached in any way. If
* @extension{EXT,direct_state_access} is not available, the texture * @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 * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{GetTexLevelParameter} or @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} * @fn_gl{GetTexLevelParameter} or @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_WIDTH} and @def_gl{TEXTURE_HEIGHT} * 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) * @return Reference to self (for method chaining)
* *
* Sets wrapping type for coordinates out of (0, textureSizeInGivenDirection-1) * Sets wrapping type for coordinates out of (0, textureSizeInGivenDirection-1)
* range for rectangle textures. If @extension{EXT,direct_state_access} * range. If @extension{EXT,direct_state_access} is not available, the
* is not available, the texture is bound to some layer before the * texture is bound to some texture unit before the operation. Initial
* operation. Initial value is @ref Sampler::Wrapping::ClampToEdge. * value is @ref Sampler::Wrapping::ClampToEdge.
* @attention Only @ref Sampler::Wrapping::ClampToEdge and * @attention Only @ref Sampler::Wrapping::ClampToEdge and
* @ref Sampler::Wrapping::ClampToBorder is supported on this * @ref Sampler::Wrapping::ClampToBorder is supported on this
* texture type. * texture type.
@ -165,10 +165,10 @@ class RectangleTexture: public AbstractTexture {
* allowed. * allowed.
* *
* If @extension{EXT,direct_state_access} is not available, the texture * If @extension{EXT,direct_state_access} is not available, the texture
* is bound to some layer before the operation. If @extension{ARB,texture_storage} * is bound to some texture unit before the operation. If
* (part of OpenGL 4.2), OpenGL ES 3.0 or @es_extension{EXT,texture_storage} * @extension{ARB,texture_storage} (part of OpenGL 4.2), OpenGL ES 3.0
* in OpenGL ES 2.0 is not available, the feature is emulated with * or @es_extension{EXT,texture_storage} in OpenGL ES 2.0 is not
* @ref setImage() call. * available, the feature is emulated with @ref setImage() call.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexStorage2D} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexStorage2D}
* or @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}, * or @fn_gl_extension{TextureStorage2D,EXT,direct_state_access},
* eventually @fn_gl{TexImage2D} or * eventually @fn_gl{TexImage2D} or
@ -189,7 +189,7 @@ class RectangleTexture: public AbstractTexture {
* @ref imageSize(). * @ref imageSize().
* *
* If @extension{EXT,direct_state_access} is not available, the * 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 * @extension{ARB,robustness} is available, the operation is protected
* from buffer overflow. However, if both @extension{EXT,direct_state_access} * from buffer overflow. However, if both @extension{EXT,direct_state_access}
* and @extension{ARB,robustness} are available, the DSA version is * 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. * use @ref setStorage() and @ref setSubImage() instead.
* *
* If @extension{EXT,direct_state_access} is not available, the * 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} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexImage2D}
* or @fn_gl_extension{TextureImage2D,EXT,direct_state_access} * or @fn_gl_extension{TextureImage2D,EXT,direct_state_access}
*/ */
@ -260,7 +260,7 @@ class RectangleTexture: public AbstractTexture {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If @extension{EXT,direct_state_access} is not available, the * 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}, * @see @ref setStorage(), @ref setImage(), @fn_gl{ActiveTexture},
* @fn_gl{BindTexture} and @fn_gl{TexSubImage2D} or * @fn_gl{BindTexture} and @fn_gl{TexSubImage2D} or
* @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access} * @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}

2
src/Magnum/Shaders/AbstractVector.h

@ -49,7 +49,7 @@ template<UnsignedInt dimensions> class AbstractVector: public AbstractShaderProg
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
enum: Int { enum: Int {
/** /**
* Layer for vector texture * Vector texture binding unit
* @deprecated Use @ref Magnum::Shaders::AbstractVector::setVectorTexture() "setVectorTexture()" instead. * @deprecated Use @ref Magnum::Shaders::AbstractVector::setVectorTexture() "setVectorTexture()" instead.
*/ */
VectorTextureLayer = 16 VectorTextureLayer = 16

3
src/Magnum/Shaders/Flat.h

@ -74,7 +74,8 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public Abstra
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
enum: Int { 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. * @deprecated use @ref Magnum::Shaders::Flat::setTexture() "setTexture()" instead.
*/ */
TextureLayer = 0 TextureLayer = 0

12
src/Magnum/Shaders/Phong.h

@ -65,24 +65,24 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
enum: Int { enum: Int {
/** /**
* Layer for ambient texture. Used only if @ref Flag::AmbientTexture * Ambient texture binding unit. Used only if
* is set. * @ref Flag::AmbientTexture is set.
* @deprecated Use @ref Magnum::Shaders::Phong::setAmbientTexture() "setAmbientTexture()" * @deprecated Use @ref Magnum::Shaders::Phong::setAmbientTexture() "setAmbientTexture()"
* instead. * instead.
*/ */
AmbientTextureLayer = 0, AmbientTextureLayer = 0,
/** /**
* Layer for diffuse texture. Used only if @ref Flag::DiffuseTexture * Diffuse texture binding unit. Used only if
* is set. * @ref Flag::DiffuseTexture is set.
* @deprecated Use @ref Magnum::Shaders::Phong::setDiffuseTexture() "setDiffuseTexture()" * @deprecated Use @ref Magnum::Shaders::Phong::setDiffuseTexture() "setDiffuseTexture()"
* instead. * instead.
*/ */
DiffuseTextureLayer = 1, DiffuseTextureLayer = 1,
/** /**
* Layer for specular texture. Used only if @ref Flag::SpecularTexture * Specular texture binding unit. Used only if
* is set. * @ref Flag::SpecularTexture is set.
* @deprecated Use @ref Magnum::Shaders::Phong::setSpecularTexture() "setSpecularTexture()" * @deprecated Use @ref Magnum::Shaders::Phong::setSpecularTexture() "setSpecularTexture()"
* instead. * instead.
*/ */

41
src/Magnum/Texture.h

@ -173,7 +173,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* *
* The result is not cached in any way. If * The result is not cached in any way. If
* @extension{EXT,direct_state_access} is not available, the texture * @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 * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{GetTexLevelParameter} or @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} * @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}. * with @def_gl{TEXTURE_WIDTH}, @def_gl{TEXTURE_HEIGHT} or @def_gl{TEXTURE_DEPTH}.
@ -194,8 +194,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* *
* Sets filter used when the object pixel size is smaller than the * Sets filter used when the object pixel size is smaller than the
* texture size. If @extension{EXT,direct_state_access} is not * texture size. If @extension{EXT,direct_state_access} is not
* available, the texture is bound to some layer before the operation. * available, the texture is bound to some texture unit before the
* Initial value is (@ref Sampler::Filter::Nearest, @ref Sampler::Mipmap::Linear). * operation. Initial value is {@ref Sampler::Filter::Nearest,
* @ref Sampler::Mipmap::Linear}.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_MIN_FILTER} * with @def_gl{TEXTURE_MIN_FILTER}
@ -212,8 +213,8 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* *
* Sets filter used when the object pixel size is larger than largest * Sets filter used when the object pixel size is larger than largest
* texture size. If @extension{EXT,direct_state_access} is not * texture size. If @extension{EXT,direct_state_access} is not
* available, the texture is bound to some layer before the operation. * available, the texture is bound to some texture unit before the
* Initial value is @ref Sampler::Filter::Linear. * operation. Initial value is @ref Sampler::Filter::Linear.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_MAG_FILTER} * with @def_gl{TEXTURE_MAG_FILTER}
@ -228,11 +229,10 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @param wrapping Wrapping type for all texture dimensions * @param wrapping Wrapping type for all texture dimensions
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Sets wrapping type for coordinates out of range (0, 1) for normal * Sets wrapping type for coordinates out of range (0.0f, 1.0f). If
* textures and (0, textureSizeInGivenDirection-1) for rectangle * @extension{EXT,direct_state_access} is not available, the texture is
* textures. If @extension{EXT,direct_state_access} is not available, * bound to some texture unit before the operation. Initial value is
* the texture is bound to some layer before the operation. Initial * @ref Sampler::Wrapping::Repeat.
* value is @ref Sampler::Wrapping::Repeat.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_WRAP_S}, @def_gl{TEXTURE_WRAP_T}, * with @def_gl{TEXTURE_WRAP_S}, @def_gl{TEXTURE_WRAP_T},
@ -249,7 +249,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* *
* Border color when wrapping is set to @ref Sampler::Wrapping::ClampToBorder. * Border color when wrapping is set to @ref Sampler::Wrapping::ClampToBorder.
* If @extension{EXT,direct_state_access} is not available, the texture * 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}`. * `{0.0f, 0.0f, 0.0f, 0.0f}`.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access} * or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
@ -270,7 +270,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @extension{EXT,texture_filter_anisotropic} (desktop or ES) is not * @extension{EXT,texture_filter_anisotropic} (desktop or ES) is not
* available, this function does nothing. If * available, this function does nothing. If
* @extension{EXT,direct_state_access} is not available, the texture is * @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}, * @see @ref Sampler::maxMaxAnisotropy(), @fn_gl{ActiveTexture},
* @fn_gl{BindTexture} and @fn_gl{TexParameter} or * @fn_gl{BindTexture} and @fn_gl{TexParameter} or
* @fn_gl_extension{TextureParameter,EXT,direct_state_access} with * @fn_gl_extension{TextureParameter,EXT,direct_state_access} with
@ -295,10 +295,11 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* allowed. * allowed.
* *
* If @extension{EXT,direct_state_access} is not available, the texture * If @extension{EXT,direct_state_access} is not available, the texture
* is bound to some layer before the operation. If @extension{ARB,texture_storage} * is bound to some texture unit before the operation. If
* (part of OpenGL 4.2), OpenGL ES 3.0 or @es_extension{EXT,texture_storage} * @extension{ARB,texture_storage} (part of OpenGL 4.2), OpenGL ES 3.0
* in OpenGL ES 2.0 is not available, the feature is emulated with * or @es_extension{EXT,texture_storage} in OpenGL ES 2.0 is not
* sequence of @ref setImage() calls. * available, the feature is emulated with sequence of @ref setImage()
* calls.
* @todo allow the user to specify ColorType explicitly to avoid * @todo allow the user to specify ColorType explicitly to avoid
* issues in WebGL (see setSubImage()) * issues in WebGL (see setSubImage())
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
@ -327,7 +328,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @ref imageSize(). * @ref imageSize().
* *
* If @extension{EXT,direct_state_access} is not available, the * 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 * @extension{ARB,robustness} is available, the operation is protected
* from buffer overflow. However, if both @extension{EXT,direct_state_access} * from buffer overflow. However, if both @extension{EXT,direct_state_access}
* and @extension{ARB,robustness} are available, the DSA version is * and @extension{ARB,robustness} are available, the DSA version is
@ -371,7 +372,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @ref setStorage() and @ref setSubImage() instead. * @ref setStorage() and @ref setSubImage() instead.
* *
* If @extension{EXT,direct_state_access} is not available, the * 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 * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexImage1D}/@fn_gl{TexImage2D}/@fn_gl{TexImage3D} or * @fn_gl{TexImage1D}/@fn_gl{TexImage2D}/@fn_gl{TexImage3D} or
* @fn_gl_extension{TextureImage1D,EXT,direct_state_access}/ * @fn_gl_extension{TextureImage1D,EXT,direct_state_access}/
@ -405,7 +406,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If @extension{EXT,direct_state_access} is not available, the * 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 * @attention In @ref MAGNUM_TARGET_WEBGL "WebGL" the @ref ColorType of
* data passed in @p image must match the original one specified * data passed in @p image must match the original one specified
@ -442,7 +443,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If @extension{EXT,direct_state_access} is not available, the texture * 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}, * @see setMinificationFilter(), @fn_gl{ActiveTexture},
* @fn_gl{BindTexture} and @fn_gl{GenerateMipmap} or * @fn_gl{BindTexture} and @fn_gl{GenerateMipmap} or
* @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access} * @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access}

6
src/Magnum/TextureArray.h

@ -158,7 +158,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* allowed. * allowed.
* *
* If @extension{EXT,direct_state_access} is not available, the texture * 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 * @extension{ARB,texture_storage} (part of OpenGL 4.2) or OpenGL ES
* 3.0 is not available, the feature is emulated with sequence of * 3.0 is not available, the feature is emulated with sequence of
* @ref setImage() calls. * @ref setImage() calls.
@ -200,7 +200,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* @ref setStorage() and @ref setSubImage() instead. * @ref setStorage() and @ref setSubImage() instead.
* *
* If @extension{EXT,direct_state_access} is not available, the * 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 * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexImage2D}/@fn_gl{TexImage3D} or * @fn_gl{TexImage2D}/@fn_gl{TexImage3D} or
* @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/ * @fn_gl_extension{TextureImage2D,EXT,direct_state_access}/
@ -233,7 +233,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If @extension{EXT,direct_state_access} is not available, the * 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}, * @see @ref setStorage(), @ref setImage(), @fn_gl{ActiveTexture},
* @fn_gl{BindTexture} and @fn_gl{TexSubImage2D}/@fn_gl{TexSubImage3D} * @fn_gl{BindTexture} and @fn_gl{TexSubImage2D}/@fn_gl{TexSubImage3D}
* or @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}/ * or @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}/

6
src/Magnum/TextureTools/DistanceField.cpp

@ -63,12 +63,12 @@ class DistanceFieldShader: public AbstractShaderProgram {
} }
DistanceFieldShader& setTexture(Texture2D& texture) { DistanceFieldShader& setTexture(Texture2D& texture) {
texture.bind(TextureLayer); texture.bind(TextureUnit);
return *this; return *this;
} }
private: private:
enum: Int { TextureLayer = 8 }; enum: Int { TextureUnit = 8 };
Int radiusUniform, Int radiusUniform,
scalingUniform, scalingUniform,
@ -130,7 +130,7 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1)
if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>()) if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::shading_language_420pack>())
#endif #endif
{ {
setUniform(uniformLocation("textureData"), TextureLayer); setUniform(uniformLocation("textureData"), TextureUnit);
} }
} }

Loading…
Cancel
Save