From 3759d26a7d32761b38c6eb9f24db6e29d3358861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 30 Mar 2020 15:37:11 +0200 Subject: [PATCH] Shaders: NO, these are not layers. --- src/Magnum/Shaders/AbstractVector.cpp | 2 +- src/Magnum/Shaders/AbstractVector.h | 6 ++--- src/Magnum/Shaders/DistanceFieldVector.cpp | 2 +- src/Magnum/Shaders/Flat.cpp | 6 ++--- src/Magnum/Shaders/Phong.cpp | 26 +++++++++++----------- src/Magnum/Shaders/Vector.cpp | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Magnum/Shaders/AbstractVector.cpp b/src/Magnum/Shaders/AbstractVector.cpp index ea2d5959d..27a9e668e 100644 --- a/src/Magnum/Shaders/AbstractVector.cpp +++ b/src/Magnum/Shaders/AbstractVector.cpp @@ -31,7 +31,7 @@ namespace Magnum { namespace Shaders { template AbstractVector& AbstractVector::bindVectorTexture(GL::Texture2D& texture) { - texture.bind(VectorTextureLayer); + texture.bind(VectorTextureUnit); return *this; } diff --git a/src/Magnum/Shaders/AbstractVector.h b/src/Magnum/Shaders/AbstractVector.h index 626e113db..9b6895445 100644 --- a/src/Magnum/Shaders/AbstractVector.h +++ b/src/Magnum/Shaders/AbstractVector.h @@ -98,9 +98,9 @@ template class AbstractVector: public GL::AbstractShader #endif /* Those textures are quite specific (and likely reused multiple times per frame for e.g. text rendering, so put them in a specific slot. - Older iOS (and iOS WebGL) has only 8 texture binding slots, so can't - go above that. Binding 7 is used by TextureTools::DistanceField. */ - enum: Int { VectorTextureLayer = 6 }; + Older iOS (and iOS WebGL) has only 8 texture units, so can't go + above that. Unit 7 is used by TextureTools::DistanceField. */ + enum: Int { VectorTextureUnit = 6 }; explicit AbstractVector(NoCreateT) noexcept: GL::AbstractShaderProgram{NoCreate} {} explicit AbstractVector() = default; diff --git a/src/Magnum/Shaders/DistanceFieldVector.cpp b/src/Magnum/Shaders/DistanceFieldVector.cpp index 6b167371e..27233b908 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.cpp +++ b/src/Magnum/Shaders/DistanceFieldVector.cpp @@ -99,7 +99,7 @@ template DistanceFieldVector::DistanceFieldV #endif { GL::AbstractShaderProgram::setUniform(GL::AbstractShaderProgram::uniformLocation("vectorTexture"), - AbstractVector::VectorTextureLayer); + AbstractVector::VectorTextureUnit); } /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ diff --git a/src/Magnum/Shaders/Flat.cpp b/src/Magnum/Shaders/Flat.cpp index 7b923b48a..e029d635b 100644 --- a/src/Magnum/Shaders/Flat.cpp +++ b/src/Magnum/Shaders/Flat.cpp @@ -42,7 +42,7 @@ namespace Magnum { namespace Shaders { namespace { - enum: Int { TextureLayer = 0 }; + enum: Int { TextureUnit = 0 }; } template Flat::Flat(const Flags flags): _flags(flags) { @@ -125,7 +125,7 @@ template Flat::Flat(const Flags flags): _fla if(!GL::Context::current().isExtensionSupported(version)) #endif { - if(flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureLayer); + if(flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureUnit); } /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ @@ -158,7 +158,7 @@ template Flat& Flat::setColor(co template Flat& Flat::bindTexture(GL::Texture2D& texture) { CORRADE_ASSERT(_flags & Flag::Textured, "Shaders::Flat::bindTexture(): the shader was not created with texturing enabled", *this); - texture.bind(TextureLayer); + texture.bind(TextureUnit); return *this; } diff --git a/src/Magnum/Shaders/Phong.cpp b/src/Magnum/Shaders/Phong.cpp index 3c55782bb..fe3d2e5ce 100644 --- a/src/Magnum/Shaders/Phong.cpp +++ b/src/Magnum/Shaders/Phong.cpp @@ -47,10 +47,10 @@ namespace Magnum { namespace Shaders { namespace { enum: Int { - AmbientTextureLayer = 0, - DiffuseTextureLayer = 1, - SpecularTextureLayer = 2, - NormalTextureLayer = 3 + AmbientTextureUnit = 0, + DiffuseTextureUnit = 1, + SpecularTextureUnit = 2, + NormalTextureUnit = 3 }; } @@ -179,11 +179,11 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l if(flags && !GL::Context::current().isExtensionSupported(version)) #endif { - if(flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"), AmbientTextureLayer); + if(flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"), AmbientTextureUnit); if(lightCount) { - if(flags & Flag::DiffuseTexture) setUniform(uniformLocation("diffuseTexture"), DiffuseTextureLayer); - if(flags & Flag::SpecularTexture) setUniform(uniformLocation("specularTexture"), SpecularTextureLayer); - if(flags & Flag::NormalTexture) setUniform(uniformLocation("normalTexture"), NormalTextureLayer); + if(flags & Flag::DiffuseTexture) setUniform(uniformLocation("diffuseTexture"), DiffuseTextureUnit); + if(flags & Flag::SpecularTexture) setUniform(uniformLocation("specularTexture"), SpecularTextureUnit); + if(flags & Flag::NormalTexture) setUniform(uniformLocation("normalTexture"), NormalTextureUnit); } } @@ -216,7 +216,7 @@ Phong& Phong::setAmbientColor(const Magnum::Color4& color) { Phong& Phong::bindAmbientTexture(GL::Texture2D& texture) { CORRADE_ASSERT(_flags & Flag::AmbientTexture, "Shaders::Phong::bindAmbientTexture(): the shader was not created with ambient texture enabled", *this); - texture.bind(AmbientTextureLayer); + texture.bind(AmbientTextureUnit); return *this; } @@ -228,7 +228,7 @@ Phong& Phong::setDiffuseColor(const Magnum::Color4& color) { Phong& Phong::bindDiffuseTexture(GL::Texture2D& texture) { CORRADE_ASSERT(_flags & Flag::DiffuseTexture, "Shaders::Phong::bindDiffuseTexture(): the shader was not created with diffuse texture enabled", *this); - if(_lightCount) texture.bind(DiffuseTextureLayer); + if(_lightCount) texture.bind(DiffuseTextureUnit); return *this; } @@ -240,21 +240,21 @@ Phong& Phong::setSpecularColor(const Magnum::Color4& color) { Phong& Phong::bindSpecularTexture(GL::Texture2D& texture) { CORRADE_ASSERT(_flags & Flag::SpecularTexture, "Shaders::Phong::bindSpecularTexture(): the shader was not created with specular texture enabled", *this); - if(_lightCount) texture.bind(SpecularTextureLayer); + if(_lightCount) texture.bind(SpecularTextureUnit); return *this; } Phong& Phong::bindNormalTexture(GL::Texture2D& texture) { CORRADE_ASSERT(_flags & Flag::NormalTexture, "Shaders::Phong::bindNormalTexture(): the shader was not created with normal texture enabled", *this); - if(_lightCount) texture.bind(NormalTextureLayer); + if(_lightCount) texture.bind(NormalTextureUnit); return *this; } Phong& Phong::bindTextures(GL::Texture2D* ambient, GL::Texture2D* diffuse, GL::Texture2D* specular, GL::Texture2D* normal) { CORRADE_ASSERT(_flags & (Flag::AmbientTexture|Flag::DiffuseTexture|Flag::SpecularTexture|Flag::NormalTexture), "Shaders::Phong::bindTextures(): the shader was not created with any textures enabled", *this); - GL::AbstractTexture::bind(AmbientTextureLayer, {ambient, diffuse, specular, normal}); + GL::AbstractTexture::bind(AmbientTextureUnit, {ambient, diffuse, specular, normal}); return *this; } diff --git a/src/Magnum/Shaders/Vector.cpp b/src/Magnum/Shaders/Vector.cpp index da96dc009..b9255bb51 100644 --- a/src/Magnum/Shaders/Vector.cpp +++ b/src/Magnum/Shaders/Vector.cpp @@ -96,7 +96,7 @@ template Vector::Vector(const Flags flags): if(!GL::Context::current().isExtensionSupported(version)) #endif { - GL::AbstractShaderProgram::setUniform(GL::AbstractShaderProgram::uniformLocation("vectorTexture"), AbstractVector::VectorTextureLayer); + GL::AbstractShaderProgram::setUniform(GL::AbstractShaderProgram::uniformLocation("vectorTexture"), AbstractVector::VectorTextureUnit); } /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */