Browse Source

Shaders: modernize coding style.

* Always prefix private members with an underscore
 * Use in-class initialization of the uniform locations
 * Use {} for default flag value
pull/197/head
Vladimír Vondruš 9 years ago
parent
commit
d6f5f43d60
  1. 12
      src/Magnum/Shaders/DistanceFieldVector.cpp
  2. 20
      src/Magnum/Shaders/DistanceFieldVector.h
  3. 6
      src/Magnum/Shaders/Flat.cpp
  4. 11
      src/Magnum/Shaders/Flat.h
  5. 18
      src/Magnum/Shaders/MeshVisualizer.cpp
  6. 32
      src/Magnum/Shaders/MeshVisualizer.h
  7. 20
      src/Magnum/Shaders/Phong.cpp
  8. 4
      src/Magnum/Shaders/Phong.frag
  9. 39
      src/Magnum/Shaders/Phong.h
  10. 8
      src/Magnum/Shaders/Vector.cpp
  11. 12
      src/Magnum/Shaders/Vector.h
  12. 4
      src/Magnum/Shaders/VertexColor.cpp
  13. 4
      src/Magnum/Shaders/VertexColor.h

12
src/Magnum/Shaders/DistanceFieldVector.cpp

@ -41,7 +41,7 @@ namespace {
template<> constexpr const char* vertexShaderName<3>() { return "AbstractVector3D.vert"; }
}
template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldVector(): transformationProjectionMatrixUniform(0), colorUniform(1), outlineColorUniform(2), outlineRangeUniform(3), smoothnessUniform(4) {
template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldVector() {
#ifdef MAGNUM_BUILD_STATIC
/* Import resources on static build, if not already */
if(!Utility::Resource::hasGroup("MagnumShaders"))
@ -82,11 +82,11 @@ template<UnsignedInt dimensions> DistanceFieldVector<dimensions>::DistanceFieldV
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
colorUniform = AbstractShaderProgram::uniformLocation("color");
outlineColorUniform = AbstractShaderProgram::uniformLocation("outlineColor");
outlineRangeUniform = AbstractShaderProgram::uniformLocation("outlineRange");
smoothnessUniform = AbstractShaderProgram::uniformLocation("smoothness");
_transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
_colorUniform = AbstractShaderProgram::uniformLocation("color");
_outlineColorUniform = AbstractShaderProgram::uniformLocation("outlineColor");
_outlineRangeUniform = AbstractShaderProgram::uniformLocation("outlineRange");
_smoothnessUniform = AbstractShaderProgram::uniformLocation("smoothness");
}
#ifndef MAGNUM_TARGET_GLES

20
src/Magnum/Shaders/DistanceFieldVector.h

@ -117,7 +117,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @return Reference to self (for method chaining)
*/
DistanceFieldVector& setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) {
AbstractShaderProgram::setUniform(transformationProjectionMatrixUniform, matrix);
AbstractShaderProgram::setUniform(_transformationProjectionMatrixUniform, matrix);
return *this;
}
@ -128,7 +128,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @see @ref setOutlineColor()
*/
DistanceFieldVector& setColor(const Color4& color) {
AbstractShaderProgram::setUniform(colorUniform, color);
AbstractShaderProgram::setUniform(_colorUniform, color);
return *this;
}
@ -139,7 +139,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @see @ref setOutlineRange(), @ref setColor()
*/
DistanceFieldVector& setOutlineColor(const Color4& color) {
AbstractShaderProgram::setUniform(outlineColorUniform, color);
AbstractShaderProgram::setUniform(_outlineColorUniform, color);
return *this;
}
@ -158,7 +158,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* @see @ref setOutlineColor()
*/
DistanceFieldVector& setOutlineRange(Float start, Float end) {
AbstractShaderProgram::setUniform(outlineRangeUniform, Vector2(start, end));
AbstractShaderProgram::setUniform(_outlineRangeUniform, Vector2(start, end));
return *this;
}
@ -171,7 +171,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
* aliased). Initial value is `0.04f`.
*/
DistanceFieldVector& setSmoothness(Float value) {
AbstractShaderProgram::setUniform(smoothnessUniform, value);
AbstractShaderProgram::setUniform(_smoothnessUniform, value);
return *this;
}
@ -184,11 +184,11 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT DistanceFieldVector
#endif
private:
Int transformationProjectionMatrixUniform,
colorUniform,
outlineColorUniform,
outlineRangeUniform,
smoothnessUniform;
Int _transformationProjectionMatrixUniform{0},
_colorUniform{1},
_outlineColorUniform{2},
_outlineRangeUniform{3},
_smoothnessUniform{4};
};
/** @brief Two-dimensional distance field vector shader */

6
src/Magnum/Shaders/Flat.cpp

@ -44,7 +44,7 @@ namespace {
template<> constexpr const char* vertexShaderName<3>() { return "Flat3D.vert"; }
}
template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): transformationProjectionMatrixUniform(0), colorUniform(1), _flags(flags) {
template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): _flags(flags) {
#ifdef MAGNUM_BUILD_STATIC
/* Import resources on static build, if not already */
if(!Utility::Resource::hasGroup("MagnumShaders"))
@ -87,8 +87,8 @@ template<UnsignedInt dimensions> Flat<dimensions>::Flat(const Flags flags): tran
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
colorUniform = uniformLocation("color");
_transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
_colorUniform = uniformLocation("color");
}
#ifndef MAGNUM_TARGET_GLES

11
src/Magnum/Shaders/Flat.h

@ -168,7 +168,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public Abstra
* @brief Constructor
* @param flags Flags
*/
explicit Flat(Flags flags = Flags());
explicit Flat(Flags flags = {});
/**
* @brief Construct without creating the underlying OpenGL object
@ -190,7 +190,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public Abstra
* @return Reference to self (for method chaining)
*/
Flat<dimensions>& setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) {
setUniform(transformationProjectionMatrixUniform, matrix);
setUniform(_transformationProjectionMatrixUniform, matrix);
return *this;
}
@ -203,7 +203,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public Abstra
* @see @ref setTexture()
*/
Flat<dimensions>& setColor(const Color4& color){
setUniform(colorUniform, color);
setUniform(_colorUniform, color);
return *this;
}
@ -217,10 +217,9 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public Abstra
Flat<dimensions>& setTexture(Texture2D& texture);
private:
Int transformationProjectionMatrixUniform,
colorUniform;
Flags _flags;
Int _transformationProjectionMatrixUniform{0},
_colorUniform{1};
};
/** @brief 2D flat shader */

18
src/Magnum/Shaders/MeshVisualizer.cpp

@ -36,7 +36,7 @@
namespace Magnum { namespace Shaders {
MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationProjectionMatrixUniform(0), viewportSizeUniform(1), colorUniform(2), wireframeColorUniform(3), wireframeWidthUniform(4), smoothnessUniform(5) {
MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} {
#ifndef MAGNUM_TARGET_GLES2
if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) {
#ifndef MAGNUM_TARGET_GLES
@ -47,7 +47,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP
#endif
}
#else
if(flags & Flag::Wireframe)
if(_flags & Flag::Wireframe)
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::standard_derivatives);
#endif
@ -128,21 +128,21 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
colorUniform = uniformLocation("color");
_transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
_colorUniform = uniformLocation("color");
if(flags & Flag::Wireframe) {
wireframeColorUniform = uniformLocation("wireframeColor");
wireframeWidthUniform = uniformLocation("wireframeWidth");
smoothnessUniform = uniformLocation("smoothness");
_wireframeColorUniform = uniformLocation("wireframeColor");
_wireframeWidthUniform = uniformLocation("wireframeWidth");
_smoothnessUniform = uniformLocation("smoothness");
if(!(flags & Flag::NoGeometryShader))
viewportSizeUniform = uniformLocation("viewportSize");
_viewportSizeUniform = uniformLocation("viewportSize");
}
}
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setColor(Color3(1.0f));
if(flags & Flag::Wireframe) {
if(_flags & Flag::Wireframe) {
setWireframeColor(Color3(0.0f));
setWireframeWidth(1.0f);
setSmoothness(2.0f);

32
src/Magnum/Shaders/MeshVisualizer.h

@ -204,7 +204,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @brief Constructor
* @param flags Flags
*/
explicit MeshVisualizer(Flags flags = Flags());
explicit MeshVisualizer(Flags flags = {});
/**
* @brief Construct without creating the underlying OpenGL object
@ -223,7 +223,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @return Reference to self (for method chaining)
*/
MeshVisualizer& setTransformationProjectionMatrix(const Matrix4& matrix) {
setUniform(transformationProjectionMatrixUniform, matrix);
setUniform(_transformationProjectionMatrixUniform, matrix);
return *this;
}
@ -235,8 +235,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* shaders are used.
*/
MeshVisualizer& setViewportSize(const Vector2& size) {
if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader))
setUniform(viewportSizeUniform, size);
if(_flags & Flag::Wireframe && !(_flags & Flag::NoGeometryShader))
setUniform(_viewportSizeUniform, size);
return *this;
}
@ -247,7 +247,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* Initial value is fully opaque white.
*/
MeshVisualizer& setColor(const Color4& color) {
setUniform(colorUniform, color);
setUniform(_colorUniform, color);
return *this;
}
@ -259,7 +259,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @ref Flag::Wireframe is enabled.
*/
MeshVisualizer& setWireframeColor(const Color4& color) {
if(flags & Flag::Wireframe) setUniform(wireframeColorUniform, color);
if(_flags & Flag::Wireframe) setUniform(_wireframeColorUniform, color);
return *this;
}
@ -271,7 +271,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* enabled.
*/
MeshVisualizer& setWireframeWidth(Float width) {
if(flags & Flag::Wireframe) setUniform(wireframeWidthUniform, width);
if(_flags & Flag::Wireframe) setUniform(_wireframeWidthUniform, width);
return *this;
}
@ -285,20 +285,20 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
MeshVisualizer& setSmoothness(Float smoothness);
private:
Flags flags;
Int transformationProjectionMatrixUniform,
viewportSizeUniform,
colorUniform,
wireframeColorUniform,
wireframeWidthUniform,
smoothnessUniform;
Flags _flags;
Int _transformationProjectionMatrixUniform{0},
_viewportSizeUniform{1},
_colorUniform{2},
_wireframeColorUniform{3},
_wireframeWidthUniform{4},
_smoothnessUniform{5};
};
CORRADE_ENUMSET_OPERATORS(MeshVisualizer::Flags)
inline MeshVisualizer& MeshVisualizer::setSmoothness(Float smoothness) {
if(flags & Flag::Wireframe)
setUniform(smoothnessUniform, smoothness);
if(_flags & Flag::Wireframe)
setUniform(_smoothnessUniform, smoothness);
return *this;
}

20
src/Magnum/Shaders/Phong.cpp

@ -44,7 +44,7 @@ namespace {
};
}
Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatrixUniform(1), normalMatrixUniform(2), lightUniform(3), diffuseColorUniform(4), ambientColorUniform(5), specularColorUniform(6), lightColorUniform(7), shininessUniform(8), _flags(flags) {
Phong::Phong(const Flags flags): _flags(flags) {
#ifdef MAGNUM_BUILD_STATIC
/* Import resources on static build, if not already */
if(!Utility::Resource::hasGroup("MagnumShaders"))
@ -90,15 +90,15 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationMatrixUniform = uniformLocation("transformationMatrix");
projectionMatrixUniform = uniformLocation("projectionMatrix");
normalMatrixUniform = uniformLocation("normalMatrix");
lightUniform = uniformLocation("light");
ambientColorUniform = uniformLocation("ambientColor");
diffuseColorUniform = uniformLocation("diffuseColor");
specularColorUniform = uniformLocation("specularColor");
lightColorUniform = uniformLocation("lightColor");
shininessUniform = uniformLocation("shininess");
_transformationMatrixUniform = uniformLocation("transformationMatrix");
_projectionMatrixUniform = uniformLocation("projectionMatrix");
_normalMatrixUniform = uniformLocation("normalMatrix");
_lightUniform = uniformLocation("light");
_ambientColorUniform = uniformLocation("ambientColor");
_diffuseColorUniform = uniformLocation("diffuseColor");
_specularColorUniform = uniformLocation("specularColor");
_lightColorUniform = uniformLocation("lightColor");
_shininessUniform = uniformLocation("shininess");
}
#ifndef MAGNUM_TARGET_GLES

4
src/Magnum/Shaders/Phong.frag

@ -59,7 +59,7 @@ uniform lowp sampler2D ambientTexture;
#endif
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 5)
layout(location = 4)
#endif
uniform lowp vec4 ambientColor
#ifndef GL_ES
@ -79,7 +79,7 @@ uniform lowp sampler2D diffuseTexture;
#endif
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 4)
layout(location = 5)
#endif
uniform lowp vec4 diffuseColor
#if !defined(GL_ES) && defined(DIFFUSE_TEXTURE)

39
src/Magnum/Shaders/Phong.h

@ -194,7 +194,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @brief Constructor
* @param flags Flags
*/
explicit Phong(Flags flags = Flags());
explicit Phong(Flags flags = {});
/**
* @brief Construct without creating the underlying OpenGL object
@ -221,7 +221,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @see @ref setAmbientTexture()
*/
Phong& setAmbientColor(const Color4& color) {
setUniform(ambientColorUniform, color);
setUniform(_ambientColorUniform, color);
return *this;
}
@ -244,7 +244,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @see @ref setDiffuseTexture()
*/
Phong& setDiffuseColor(const Color4& color) {
setUniform(diffuseColorUniform, color);
setUniform(_diffuseColorUniform, color);
return *this;
}
@ -267,7 +267,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @see @ref setSpecularTexture()
*/
Phong& setSpecularColor(const Color4& color) {
setUniform(specularColorUniform, color);
setUniform(_specularColorUniform, color);
return *this;
}
@ -300,7 +300,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* If not set, default value is `80.0f`.
*/
Phong& setShininess(Float shininess) {
setUniform(shininessUniform, shininess);
setUniform(_shininessUniform, shininess);
return *this;
}
@ -309,7 +309,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @return Reference to self (for method chaining)
*/
Phong& setTransformationMatrix(const Matrix4& matrix) {
setUniform(transformationMatrixUniform, matrix);
setUniform(_transformationMatrixUniform, matrix);
return *this;
}
@ -321,7 +321,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* must be done in the shader anyway.
*/
Phong& setNormalMatrix(const Matrix3x3& matrix) {
setUniform(normalMatrixUniform, matrix);
setUniform(_normalMatrixUniform, matrix);
return *this;
}
@ -330,7 +330,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @return Reference to self (for method chaining)
*/
Phong& setProjectionMatrix(const Matrix4& matrix) {
setUniform(projectionMatrixUniform, matrix);
setUniform(_projectionMatrixUniform, matrix);
return *this;
}
@ -339,7 +339,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @return Reference to self (for method chaining)
*/
Phong& setLightPosition(const Vector3& light) {
setUniform(lightUniform, light);
setUniform(_lightUniform, light);
return *this;
}
@ -350,22 +350,21 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* If not set, default value is `{1.0f, 1.0f, 1.0f, 1.0f}`.
*/
Phong& setLightColor(const Color4& color) {
setUniform(lightColorUniform, color);
setUniform(_lightColorUniform, color);
return *this;
}
private:
Int transformationMatrixUniform,
projectionMatrixUniform,
normalMatrixUniform,
lightUniform,
diffuseColorUniform,
ambientColorUniform,
specularColorUniform,
lightColorUniform,
shininessUniform;
Flags _flags;
Int _transformationMatrixUniform{0},
_projectionMatrixUniform{1},
_normalMatrixUniform{2},
_lightUniform{3},
_ambientColorUniform{4},
_diffuseColorUniform{5},
_specularColorUniform{6},
_lightColorUniform{7},
_shininessUniform{8};
};
CORRADE_ENUMSET_OPERATORS(Phong::Flags)

8
src/Magnum/Shaders/Vector.cpp

@ -41,7 +41,7 @@ namespace {
template<> constexpr const char* vertexShaderName<3>() { return "AbstractVector3D.vert"; }
}
template<UnsignedInt dimensions> Vector<dimensions>::Vector(): transformationProjectionMatrixUniform(0), backgroundColorUniform(1), colorUniform(2) {
template<UnsignedInt dimensions> Vector<dimensions>::Vector() {
#ifdef MAGNUM_BUILD_STATIC
/* Import resources on static build, if not already */
if(!Utility::Resource::hasGroup("MagnumShaders"))
@ -82,9 +82,9 @@ template<UnsignedInt dimensions> Vector<dimensions>::Vector(): transformationPro
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
backgroundColorUniform = AbstractShaderProgram::uniformLocation("backgroundColor");
colorUniform = AbstractShaderProgram::uniformLocation("color");
_transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix");
_backgroundColorUniform = AbstractShaderProgram::uniformLocation("backgroundColor");
_colorUniform = AbstractShaderProgram::uniformLocation("color");
}
#ifndef MAGNUM_TARGET_GLES

12
src/Magnum/Shaders/Vector.h

@ -111,7 +111,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Vector: public Abst
* @return Reference to self (for method chaining)
*/
Vector& setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) {
AbstractShaderProgram::setUniform(transformationProjectionMatrixUniform, matrix);
AbstractShaderProgram::setUniform(_transformationProjectionMatrixUniform, matrix);
return *this;
}
@ -123,7 +123,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Vector: public Abst
* @see @ref setColor()
*/
Vector& setBackgroundColor(const Color4& color) {
AbstractShaderProgram::setUniform(backgroundColorUniform, color);
AbstractShaderProgram::setUniform(_backgroundColorUniform, color);
return *this;
}
@ -134,7 +134,7 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Vector: public Abst
* @see @ref setBackgroundColor()
*/
Vector& setColor(const Color4& color) {
AbstractShaderProgram::setUniform(colorUniform, color);
AbstractShaderProgram::setUniform(_colorUniform, color);
return *this;
}
@ -147,9 +147,9 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Vector: public Abst
#endif
private:
Int transformationProjectionMatrixUniform,
backgroundColorUniform,
colorUniform;
Int _transformationProjectionMatrixUniform{0},
_backgroundColorUniform{1},
_colorUniform{2};
};
/** @brief Two-dimensional vector shader */

4
src/Magnum/Shaders/VertexColor.cpp

@ -41,7 +41,7 @@ namespace {
template<> constexpr const char* vertexShaderName<3>() { return "VertexColor3D.vert"; }
}
template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor(): transformationProjectionMatrixUniform(0) {
template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor() {
#ifdef MAGNUM_BUILD_STATIC
/* Import resources on static build, if not already */
if(!Utility::Resource::hasGroup("MagnumShaders"))
@ -82,7 +82,7 @@ template<UnsignedInt dimensions> VertexColor<dimensions>::VertexColor(): transfo
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version))
#endif
{
transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
_transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
}
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */

4
src/Magnum/Shaders/VertexColor.h

@ -124,12 +124,12 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT VertexColor: public
* Default is identity matrix.
*/
VertexColor<dimensions>& setTransformationProjectionMatrix(const MatrixTypeFor<dimensions, Float>& matrix) {
setUniform(transformationProjectionMatrixUniform, matrix);
setUniform(_transformationProjectionMatrixUniform, matrix);
return *this;
}
private:
Int transformationProjectionMatrixUniform;
Int _transformationProjectionMatrixUniform{0};
};
/** @brief 2D vertex color shader */

Loading…
Cancel
Save