Browse Source

Shaders: set default values for VertexColorShader uniforms.

Default value for matrix uniform would be zero uniform which would cause
"black screen of death".
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
14c6790701
  1. 5
      src/Shaders/VertexColorShader.cpp
  2. 2
      src/Shaders/VertexColorShader.h
  3. 6
      src/Shaders/VertexColorShader2D.vert
  4. 6
      src/Shaders/VertexColorShader3D.vert

5
src/Shaders/VertexColorShader.cpp

@ -75,6 +75,11 @@ template<UnsignedInt dimensions> VertexColorShader<dimensions>::VertexColorShade
{
transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
}
/* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */
#ifdef MAGNUM_TARGET_GLES
setTransformationProjectionMatrix(typename DimensionTraits<dimensions>::MatrixType());
#endif
}
template class VertexColorShader<2>;

2
src/Shaders/VertexColorShader.h

@ -57,6 +57,8 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT VertexColorShader:
/**
* @brief Set transformation and projection matrix
* @return Pointer to self (for method chaining)
*
* Default is identity matrix.
*/
inline VertexColorShader<dimensions>* setTransformationProjectionMatrix(const typename DimensionTraits<dimensions>::MatrixType& matrix) {
setUniform(transformationProjectionMatrixUniform, matrix);

6
src/Shaders/VertexColorShader2D.vert

@ -27,8 +27,12 @@
#define out varying
#endif
#ifndef GL_ES
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0) uniform mat3 transformationProjectionMatrix;
layout(location = 0) uniform mat3 transformationProjectionMatrix = mat3(1.0);
#else
uniform mat3 transformationProjectionMatrix = mat3(1.0);
#endif
#else
uniform highp mat3 transformationProjectionMatrix;
#endif

6
src/Shaders/VertexColorShader3D.vert

@ -27,8 +27,12 @@
#define out varying
#endif
#ifndef GL_ES
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0) uniform mat4 transformationProjectionMatrix;
layout(location = 0) uniform mat4 transformationProjectionMatrix = mat4(1.0);
#else
uniform mat4 transformationProjectionMatrix = mat4(1.0);
#endif
#else
uniform highp mat4 transformationProjectionMatrix;
#endif

Loading…
Cancel
Save