From 5cfdb60681f9a8f2adf7d8b71b259212f2b028b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 14 Dec 2022 15:00:47 +0100 Subject: [PATCH] Shaders: minor cleanup. * No need to repeat the type for all variables, unnecessary redundancy. * Reducing the amount of redundant local variables and if they stay making their definitions more localized to where they get used. * All uniform setters used the "initial value is" phrase instead of "default is", this one didn't. --- src/Magnum/Shaders/DistanceFieldVectorGL.cpp | 11 +- src/Magnum/Shaders/DistanceFieldVectorGL.h | 4 +- src/Magnum/Shaders/FlatGL.cpp | 11 +- src/Magnum/Shaders/FlatGL.h | 6 +- src/Magnum/Shaders/MeshVisualizerGL.cpp | 109 ++++++++----------- src/Magnum/Shaders/MeshVisualizerGL.h | 12 +- src/Magnum/Shaders/PhongGL.cpp | 11 +- src/Magnum/Shaders/PhongGL.h | 8 +- src/Magnum/Shaders/VectorGL.cpp | 11 +- src/Magnum/Shaders/VectorGL.h | 4 +- src/Magnum/Shaders/VertexColorGL.cpp | 11 +- 11 files changed, 77 insertions(+), 121 deletions(-) diff --git a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp index 56e05c21c..def52fe4f 100644 --- a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp +++ b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp @@ -189,11 +189,9 @@ template DistanceFieldVectorGL::DistanceFiel CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); - const GL::Context& context = GL::Context::current(); - const GL::Version version = state._version; - #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + const GL::Context& context = GL::Context::current(); + if(!context.isExtensionSupported(state._version)) #endif { #ifndef MAGNUM_TARGET_GLES2 @@ -213,7 +211,7 @@ template DistanceFieldVectorGL::DistanceFiel } #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + if(!context.isExtensionSupported(state._version)) #endif { setUniform(uniformLocation("vectorTexture"), TextureUnit); @@ -245,9 +243,6 @@ template DistanceFieldVectorGL::DistanceFiel setSmoothness(0.04f); } #endif - - static_cast(context); - static_cast(version); } template DistanceFieldVectorGL::DistanceFieldVectorGL(const Configuration& configuration): DistanceFieldVectorGL{compile(configuration)} {} diff --git a/src/Magnum/Shaders/DistanceFieldVectorGL.h b/src/Magnum/Shaders/DistanceFieldVectorGL.h index 56ef04d3d..518a255a0 100644 --- a/src/Magnum/Shaders/DistanceFieldVectorGL.h +++ b/src/Magnum/Shaders/DistanceFieldVectorGL.h @@ -728,8 +728,8 @@ template class DistanceFieldVectorGL::Config private: Flags _flags; #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt _materialCount = 1; - UnsignedInt _drawCount = 1; + UnsignedInt _materialCount = 1, + _drawCount = 1; #endif }; diff --git a/src/Magnum/Shaders/FlatGL.cpp b/src/Magnum/Shaders/FlatGL.cpp index d97b98f24..70498f87b 100644 --- a/src/Magnum/Shaders/FlatGL.cpp +++ b/src/Magnum/Shaders/FlatGL.cpp @@ -264,11 +264,9 @@ template FlatGL::FlatGL(CompileState&& state CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); - const GL::Context& context = GL::Context::current(); - const GL::Version version = state._version; - #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + const GL::Context& context = GL::Context::current(); + if(!context.isExtensionSupported(state._version)) #endif { #ifndef MAGNUM_TARGET_GLES2 @@ -293,7 +291,7 @@ template FlatGL::FlatGL(CompileState&& state } #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + if(!context.isExtensionSupported(state._version)) #endif { if(_flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureUnit); @@ -326,9 +324,6 @@ template FlatGL::FlatGL(CompileState&& state /* Object ID is zero by default */ } #endif - - static_cast(version); - static_cast(context); } template FlatGL::FlatGL(const Configuration& configuration): FlatGL{compile(configuration)} {} diff --git a/src/Magnum/Shaders/FlatGL.h b/src/Magnum/Shaders/FlatGL.h index 0d949d98e..2d24c85a7 100644 --- a/src/Magnum/Shaders/FlatGL.h +++ b/src/Magnum/Shaders/FlatGL.h @@ -797,7 +797,7 @@ template class MAGNUM_SHADERS_EXPORT FlatGL: public GL:: * * Expects that the shader was created with @ref Flag::ObjectId * enabled. Value set here is written to the @ref ObjectIdOutput, see - * @ref Shaders-FlatGL-object-id for more information. Default is + * @ref Shaders-FlatGL-object-id for more information. Initial value is * @cpp 0 @ce. If @ref Flag::InstancedObjectId and/or * @ref Flag::ObjectIdTexture is enabled as well, this value is added * to the ID coming from the @ref ObjectId attribute and/or the @@ -1141,8 +1141,8 @@ template class FlatGL::Configuration { private: Flags _flags; #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt _materialCount = 1; - UnsignedInt _drawCount = 1; + UnsignedInt _materialCount = 1, + _drawCount = 1; #endif }; diff --git a/src/Magnum/Shaders/MeshVisualizerGL.cpp b/src/Magnum/Shaders/MeshVisualizerGL.cpp index a9288357b..484705ab9 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.cpp +++ b/src/Magnum/Shaders/MeshVisualizerGL.cpp @@ -398,10 +398,6 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration "Shaders::MeshVisualizerGL2D: draw count can't be zero", CompileState{NoCreate}); #endif - #ifndef MAGNUM_TARGET_GLES - const GL::Context& context = GL::Context::current(); - #endif - Utility::Resource rs{"MagnumShadersGL"}; GL::Shader vert{NoCreate}; GL::Shader frag{NoCreate}; @@ -483,6 +479,7 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration /* ES3 has this done in the shader directly */ #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES + const GL::Context& context = GL::Context::current(); if(!context.isExtensionSupported(version)) #endif { @@ -543,48 +540,45 @@ MeshVisualizerGL2D::MeshVisualizerGL2D(CompileState&& state): MeshVisualizerGL2D else CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); - const GL::Context& context = GL::Context::current(); - const GL::Version version = state._version; - const Flags flags = state.flags(); - #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + const GL::Context& context = GL::Context::current(); + if(!context.isExtensionSupported(state._version)) #endif { /* This one is used also in the UBO case as it's usually a global setting */ - if((flags & Flag::Wireframe) && !(flags & Flag::NoGeometryShader)) + if((flags() & Flag::Wireframe) && !(flags() & Flag::NoGeometryShader)) _viewportSizeUniform = uniformLocation("viewportSize"); #ifndef MAGNUM_TARGET_GLES2 - if(flags >= Flag::UniformBuffers) { + if(flags() >= Flag::UniformBuffers) { if(_drawCount > 1) _drawOffsetUniform = uniformLocation("drawOffset"); } else #endif { _transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); #ifndef MAGNUM_TARGET_GLES2 - if(flags & Flag::TextureTransformation) + if(flags() & Flag::TextureTransformation) _textureMatrixUniform = uniformLocation("textureMatrix"); - if(flags & Flag::TextureArrays) + if(flags() & Flag::TextureArrays) _textureLayerUniform = uniformLocation("textureLayer"); #endif - if(flags & (Flag::Wireframe + if(flags() & (Flag::Wireframe #ifndef MAGNUM_TARGET_GLES2 |Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId #endif )) _colorUniform = uniformLocation("color"); - if(flags & Flag::Wireframe) { + if(flags() & Flag::Wireframe) { _wireframeColorUniform = uniformLocation("wireframeColor"); _wireframeWidthUniform = uniformLocation("wireframeWidth"); _smoothnessUniform = uniformLocation("smoothness"); } #ifndef MAGNUM_TARGET_GLES2 - if(flags & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { + if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { _colorMapOffsetScaleUniform = uniformLocation("colorMapOffsetScale"); } - if(flags & Flag::ObjectId) + if(flags() & Flag::ObjectId) _objectIdUniform = uniformLocation("objectId"); #endif } @@ -592,20 +586,20 @@ MeshVisualizerGL2D::MeshVisualizerGL2D(CompileState&& state): MeshVisualizerGL2D #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - if(flags && !context.isExtensionSupported(version)) + if(flags() && !context.isExtensionSupported(state._version)) #endif { - if(flags & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { + if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { setUniform(uniformLocation("colorMapTexture"), ColorMapTextureUnit); } #ifndef MAGNUM_TARGET_GLES2 - if(flags >= Flag::ObjectIdTexture) + if(flags() >= Flag::ObjectIdTexture) setUniform(uniformLocation("objectIdTextureData"), ObjectIdTextureUnit); - if(flags >= Flag::UniformBuffers) { + if(flags() >= Flag::UniformBuffers) { setUniformBlockBinding(uniformBlockIndex("TransformationProjection"), TransformationProjectionBufferBinding); setUniformBlockBinding(uniformBlockIndex("Draw"), DrawBufferBinding); setUniformBlockBinding(uniformBlockIndex("Material"), MaterialBufferBinding); - if(flags & Flag::TextureTransformation) + if(flags() & Flag::TextureTransformation) setUniformBlockBinding(uniformBlockIndex("TextureTransformation"), TextureTransformationBufferBinding); } #endif @@ -615,34 +609,31 @@ MeshVisualizerGL2D::MeshVisualizerGL2D(CompileState&& state): MeshVisualizerGL2D /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ #ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2 - if(flags >= Flag::UniformBuffers) { + if(flags() >= Flag::UniformBuffers) { /* Viewport size is zero by default */ /* Draw offset is zero by default */ } else #endif { setTransformationProjectionMatrix(Matrix3{Math::IdentityInit}); - if(flags & (Flag::Wireframe + if(flags() & (Flag::Wireframe #ifndef MAGNUM_TARGET_GLES2 |Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId #endif )) setColor(Color3(1.0f)); - if(flags & Flag::Wireframe) { + if(flags() & Flag::Wireframe) { /* Viewport size is zero by default */ setWireframeColor(Color3{0.0f}); setWireframeWidth(1.0f); setSmoothness(2.0f); } #ifndef MAGNUM_TARGET_GLES2 - if(flags & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) + if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) setColorMapTransformation(1.0f/512.0f, 1.0f/256.0f); #endif } #endif - - static_cast(context); - static_cast(version); } MeshVisualizerGL2D::MeshVisualizerGL2D(const Configuration& configuration): MeshVisualizerGL2D{compile(configuration)} {} @@ -753,10 +744,6 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(const Configuration "Shaders::MeshVisualizerGL3D: draw count can't be zero", CompileState{NoCreate}); #endif - #ifndef MAGNUM_TARGET_GLES - const GL::Context& context = GL::Context::current(); - #endif - Utility::Resource rs{"MagnumShadersGL"}; GL::Shader vert{NoCreate}; GL::Shader frag{NoCreate}; @@ -872,6 +859,7 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(const Configuration /* ES3 has this done in the shader directly */ #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES + const GL::Context& context = GL::Context::current(); if(!context.isExtensionSupported(version)) #endif { @@ -903,7 +891,6 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(const Configuration configuration.flags() & Flag::BitangentFromTangentDirection) out.bindAttributeLocation(Normal::Location, "normal"); #endif - #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!context.isVersionSupported(GL::Version::GL310)) @@ -948,25 +935,22 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D else CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); - const GL::Context& context = GL::Context::current(); - const GL::Version version = state._version; - Flags flags = state.flags(); - #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + const GL::Context& context = GL::Context::current(); + if(!context.isExtensionSupported(state._version)) #endif { /* This one is used also in the UBO case as it's usually a global setting */ - if(((flags & Flag::Wireframe) && !(flags & Flag::NoGeometryShader)) + if(((flags() & Flag::Wireframe) && !(flags() & Flag::NoGeometryShader)) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - || (flags & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)) + || (flags() & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)) #endif ) _viewportSizeUniform = uniformLocation("viewportSize"); #ifndef MAGNUM_TARGET_GLES2 - if(flags >= Flag::UniformBuffers) { + if(flags() >= Flag::UniformBuffers) { if(_drawCount > 1) _drawOffsetUniform = uniformLocation("drawOffset"); } else #endif @@ -974,22 +958,22 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D _transformationMatrixUniform = uniformLocation("transformationMatrix"); _projectionMatrixUniform = uniformLocation("projectionMatrix"); #ifndef MAGNUM_TARGET_GLES2 - if(flags & Flag::TextureTransformation) + if(flags() & Flag::TextureTransformation) _textureMatrixUniform = uniformLocation("textureMatrix"); - if(flags & Flag::TextureArrays) + if(flags() & Flag::TextureArrays) _textureLayerUniform = uniformLocation("textureLayer"); #endif - if(flags & (Flag::Wireframe + if(flags() & (Flag::Wireframe #ifndef MAGNUM_TARGET_GLES2 |Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId #endif )) _colorUniform = uniformLocation("color"); - if(flags & Flag::Wireframe) { + if(flags() & Flag::Wireframe) { _wireframeColorUniform = uniformLocation("wireframeColor"); _wireframeWidthUniform = uniformLocation("wireframeWidth"); } - if(flags & (Flag::Wireframe + if(flags() & (Flag::Wireframe #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) |Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection #endif @@ -997,14 +981,14 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D _smoothnessUniform = uniformLocation("smoothness"); } #ifndef MAGNUM_TARGET_GLES2 - if(flags & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { + if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { _colorMapOffsetScaleUniform = uniformLocation("colorMapOffsetScale"); } - if(flags & Flag::ObjectId) + if(flags() & Flag::ObjectId) _objectIdUniform = uniformLocation("objectId"); #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - if(flags & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)) { + if(flags() & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)) { _normalMatrixUniform = uniformLocation("normalMatrix"); _lineWidthUniform = uniformLocation("lineWidth"); _lineLengthUniform = uniformLocation("lineLength"); @@ -1015,21 +999,21 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - if(flags && !context.isExtensionSupported(version)) + if(flags() && !context.isExtensionSupported(state._version)) #endif { - if(flags & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { + if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { setUniform(uniformLocation("colorMapTexture"), ColorMapTextureUnit); } #ifndef MAGNUM_TARGET_GLES2 - if(flags >= Flag::ObjectIdTexture) + if(flags() >= Flag::ObjectIdTexture) setUniform(uniformLocation("objectIdTextureData"), ObjectIdTextureUnit); - if(flags >= Flag::UniformBuffers) { + if(flags() >= Flag::UniformBuffers) { setUniformBlockBinding(uniformBlockIndex("Projection"), ProjectionBufferBinding); setUniformBlockBinding(uniformBlockIndex("Transformation"), TransformationBufferBinding); setUniformBlockBinding(uniformBlockIndex("Draw"), DrawBufferBinding); setUniformBlockBinding(uniformBlockIndex("Material"), MaterialBufferBinding); - if(flags & Flag::TextureTransformation) + if(flags() & Flag::TextureTransformation) setUniformBlockBinding(uniformBlockIndex("TextureTransformation"), TextureTransformationBufferBinding); } #endif @@ -1039,7 +1023,7 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ #ifdef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2 - if(flags >= Flag::UniformBuffers) { + if(flags() >= Flag::UniformBuffers) { /* Viewport size is zero by default */ /* Draw offset is zero by default */ } else @@ -1047,18 +1031,18 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D { setTransformationMatrix(Matrix4{Math::IdentityInit}); setProjectionMatrix(Matrix4{Math::IdentityInit}); - if(flags & (Flag::Wireframe + if(flags() & (Flag::Wireframe #ifndef MAGNUM_TARGET_GLES2 |Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId #endif )) setColor(Color3(1.0f)); - if(flags & Flag::Wireframe) { + if(flags() & Flag::Wireframe) { /* Viewport size is zero by default */ setWireframeColor(Color3{0.0f}); setWireframeWidth(1.0f); } - if(flags & (Flag::Wireframe + if(flags() & (Flag::Wireframe #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) |Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection #endif @@ -1066,11 +1050,11 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D setSmoothness(2.0f); } #ifndef MAGNUM_TARGET_GLES2 - if(flags & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) + if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) setColorMapTransformation(1.0f/512.0f, 1.0f/256.0f); #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - if(flags & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)) { + if(flags() & (Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection)) { setNormalMatrix(Matrix3x3{Math::IdentityInit}); setLineWidth(1.0f); setLineLength(1.0f); @@ -1078,9 +1062,6 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D #endif } #endif - - static_cast(context); - static_cast(version); } MeshVisualizerGL3D::MeshVisualizerGL3D(const Configuration& configuration): MeshVisualizerGL3D{compile(configuration)} {} diff --git a/src/Magnum/Shaders/MeshVisualizerGL.h b/src/Magnum/Shaders/MeshVisualizerGL.h index 233ba0a4c..a5529e92e 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.h +++ b/src/Magnum/Shaders/MeshVisualizerGL.h @@ -625,7 +625,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua * @return Reference to self (for method chaining) * @m_since_latest * - * Expects that @ref Flag::ObjectId is enabled. Default is + * Expects that @ref Flag::ObjectId is enabled. Initial value is * @cpp 0 @ce. If @ref Flag::InstancedObjectId is enabled as well, this * value is added to the ID coming from the @ref ObjectId attribute. * @@ -960,8 +960,8 @@ class MeshVisualizerGL2D::Configuration { private: Flags _flags; #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt _materialCount = 1; - UnsignedInt _drawCount = 1; + UnsignedInt _materialCount = 1, + _drawCount = 1; #endif }; @@ -2036,7 +2036,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua * @return Reference to self (for method chaining) * @m_since_latest * - * Expects that @ref Flag::ObjectId is enabled. Default is + * Expects that @ref Flag::ObjectId is enabled. Initial value is * @cpp 0 @ce. If @ref Flag::InstancedObjectId is enabled as well, this * value is added to the ID coming from the @ref ObjectId attribute. * @@ -2548,8 +2548,8 @@ class MeshVisualizerGL3D::Configuration { private: Flags _flags; #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt _materialCount = 1; - UnsignedInt _drawCount = 1; + UnsignedInt _materialCount = 1, + _drawCount = 1; #endif }; diff --git a/src/Magnum/Shaders/PhongGL.cpp b/src/Magnum/Shaders/PhongGL.cpp index 5e77f4a7d..103eaa7e9 100644 --- a/src/Magnum/Shaders/PhongGL.cpp +++ b/src/Magnum/Shaders/PhongGL.cpp @@ -376,11 +376,9 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(std::move CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); - const GL::Context& context = GL::Context::current(); - const GL::Version version = state._version; - #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + const GL::Context& context = GL::Context::current(); + if(!context.isExtensionSupported(state._version)) #endif { #ifndef MAGNUM_TARGET_GLES2 @@ -421,7 +419,7 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(std::move } #ifndef MAGNUM_TARGET_GLES - if(_flags && !context.isExtensionSupported(version)) + if(_flags && !context.isExtensionSupported(state._version)) #endif { if(_flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"), AmbientTextureUnit); @@ -482,9 +480,6 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(std::move /* Object ID is zero by default */ } #endif - - static_cast(context); - static_cast(version); } PhongGL::PhongGL(const Configuration& configuration): PhongGL{compile(configuration)} {} diff --git a/src/Magnum/Shaders/PhongGL.h b/src/Magnum/Shaders/PhongGL.h index 484033d6a..23afc33c9 100644 --- a/src/Magnum/Shaders/PhongGL.h +++ b/src/Magnum/Shaders/PhongGL.h @@ -1048,8 +1048,8 @@ class MAGNUM_SHADERS_EXPORT PhongGL: public GL::AbstractShaderProgram { * * Expects that the shader was created with @ref Flag::ObjectId * enabled. Value set here is written to the @ref ObjectIdOutput, see - * @ref Shaders-PhongGL-object-id for more information. Default is - * @cpp 0 @ce. If @ref Flag::InstancedObjectId and/or + * @ref Shaders-PhongGL-object-id for more information. Initial value + * is @cpp 0 @ce. If @ref Flag::InstancedObjectId and/or * @ref Flag::ObjectIdTexture is enabled as well, this value is added * to the ID coming from the @ref ObjectId attribute and/or the * texture. @@ -1920,8 +1920,8 @@ class PhongGL::Configuration { Flags _flags; UnsignedInt _lightCount = 1; #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt _materialCount = 1; - UnsignedInt _drawCount = 1; + UnsignedInt _materialCount = 1, + _drawCount = 1; #endif }; diff --git a/src/Magnum/Shaders/VectorGL.cpp b/src/Magnum/Shaders/VectorGL.cpp index 4334c5685..c841011e0 100644 --- a/src/Magnum/Shaders/VectorGL.cpp +++ b/src/Magnum/Shaders/VectorGL.cpp @@ -190,11 +190,9 @@ template VectorGL::VectorGL(CompileState&& s CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); - const GL::Context& context = GL::Context::current(); - const GL::Version version = state._version; - #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + const GL::Context& context = GL::Context::current(); + if(!context.isExtensionSupported(state._version)) #endif { #ifndef MAGNUM_TARGET_GLES2 @@ -212,7 +210,7 @@ template VectorGL::VectorGL(CompileState&& s } #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + if(!context.isExtensionSupported(state._version)) #endif { setUniform(uniformLocation("vectorTexture"), TextureUnit); @@ -242,9 +240,6 @@ template VectorGL::VectorGL(CompileState&& s setColor(Color4{1.0f}); } #endif - - static_cast(context); - static_cast(version); } template VectorGL::VectorGL(const Configuration& configuration): VectorGL{compile(configuration)} {} diff --git a/src/Magnum/Shaders/VectorGL.h b/src/Magnum/Shaders/VectorGL.h index 57ab78fbf..a41caafbe 100644 --- a/src/Magnum/Shaders/VectorGL.h +++ b/src/Magnum/Shaders/VectorGL.h @@ -679,8 +679,8 @@ template class VectorGL::Configuration { private: Flags _flags; #ifndef MAGNUM_TARGET_GLES2 - UnsignedInt _materialCount = 1; - UnsignedInt _drawCount = 1; + UnsignedInt _materialCount = 1, + _drawCount = 1; #endif }; diff --git a/src/Magnum/Shaders/VertexColorGL.cpp b/src/Magnum/Shaders/VertexColorGL.cpp index abe7280e9..442820d34 100644 --- a/src/Magnum/Shaders/VertexColorGL.cpp +++ b/src/Magnum/Shaders/VertexColorGL.cpp @@ -167,11 +167,9 @@ template VertexColorGL::VertexColorGL(Compil CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); - const GL::Context& context = GL::Context::current(); - const GL::Version version = state._version; - #ifndef MAGNUM_TARGET_GLES - if(!context.isExtensionSupported(version)) + const GL::Context& context = GL::Context::current(); + if(!context.isExtensionSupported(state._version)) #endif { #ifndef MAGNUM_TARGET_GLES2 @@ -187,7 +185,7 @@ template VertexColorGL::VertexColorGL(Compil #ifndef MAGNUM_TARGET_GLES2 if(_flags >= Flag::UniformBuffers #ifndef MAGNUM_TARGET_GLES - && !context.isExtensionSupported(version) + && !context.isExtensionSupported(state._version) #endif ) { setUniformBlockBinding(uniformBlockIndex("TransformationProjection"), TransformationProjectionBufferBinding); @@ -205,9 +203,6 @@ template VertexColorGL::VertexColorGL(Compil setTransformationProjectionMatrix(MatrixTypeFor{Math::IdentityInit}); } #endif - - static_cast(context); - static_cast(version); } template VertexColorGL::VertexColorGL(const Configuration& configuration): VertexColorGL{compile(configuration)} {}