Browse Source

Shaders: added missing 3D version of FlatShader vertex shader.

Fragment shader is common for both 2D and 3D.
pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
dc798b7320
  1. 2
      src/Shaders/CMakeLists.txt
  2. 18
      src/Shaders/FlatShader.cpp
  3. 0
      src/Shaders/FlatShader.frag
  4. 19
      src/Shaders/FlatShader3D.vert

2
src/Shaders/CMakeLists.txt

@ -1,5 +1,5 @@
corrade_add_resource(MagnumShaders_RCS MagnumShaders
FlatShader2D.vert FlatShader2D.frag
FlatShader2D.vert FlatShader3D.vert FlatShader.frag
PhongShader.vert PhongShader.frag
TextShader2D.vert TextShader2D.frag
VertexColorShader2D.vert VertexColorShader3D.vert VertexColorShader.frag

18
src/Shaders/FlatShader.cpp

@ -23,17 +23,9 @@
namespace Magnum { namespace Shaders {
namespace {
template<std::uint8_t dimensions> struct ShaderName {};
template<> struct ShaderName<2> {
constexpr static const char* vertex() { return "FlatShader2D.vert"; }
constexpr static const char* fragment() { return "FlatShader2D.frag"; }
};
template<> struct ShaderName<3> {
constexpr static const char* vertex() { return "FlatShader3D.vert"; }
constexpr static const char* fragment() { return "FlatShader3D.frag"; }
};
template<std::uint8_t> constexpr const char* vertexShaderName();
template<> constexpr const char* vertexShaderName<2>() { return "FlatShader2D.vert"; }
template<> constexpr const char* vertexShaderName<3>() { return "FlatShader3D.vert"; }
}
template<std::uint8_t dimensions> FlatShader<dimensions>::FlatShader(): transformationProjectionMatrixUniform(0), colorUniform(1) {
@ -47,12 +39,12 @@ template<std::uint8_t dimensions> FlatShader<dimensions>::FlatShader(): transfor
Shader vertexShader(v, Shader::Type::Vertex);
vertexShader.addSource(rs.get("compatibility.glsl"));
vertexShader.addSource(rs.get(ShaderName<dimensions>::vertex()));
vertexShader.addSource(rs.get(vertexShaderName<dimensions>()));
attachShader(vertexShader);
Shader fragmentShader(v, Shader::Type::Fragment);
fragmentShader.addSource(rs.get("compatibility.glsl"));
fragmentShader.addSource(rs.get(ShaderName<dimensions>::fragment()));
fragmentShader.addSource(rs.get("FlatShader.frag"));
attachShader(fragmentShader);
#ifndef MAGNUM_TARGET_GLES

0
src/Shaders/FlatShader2D.frag → src/Shaders/FlatShader.frag

19
src/Shaders/FlatShader3D.vert

@ -0,0 +1,19 @@
#ifndef NEW_GLSL
#define in attribute
#endif
#ifdef EXPLICIT_UNIFORM_LOCATION
layout(location = 0) uniform mat4 transformationProjectionMatrix;
#else
uniform highp mat4 transformationProjectionMatrix;
#endif
#ifdef EXPLICIT_ATTRIB_LOCATION
layout(location = 0) in highp vec4 position;
#else
in highp vec4 position;
#endif
void main() {
gl_Position = transformationProjectionMatrix*position;
}
Loading…
Cancel
Save