Virtual Testbed
Ship dynamics simulator for extreme conditions
ShipShader.hh
1 #ifndef VTESTBED_GRAPHICS_SHIPSHADER_HH
2 #define VTESTBED_GRAPHICS_SHIPSHADER_HH
3 
4 #include <Magnum/GL/AbstractShaderProgram.h>
5 #include <Magnum/GL/Texture.h>
6 #include <Magnum/Shaders/visibility.h>
7 
8 #include <vtestbed/graphics/types.hh>
9 
10 namespace vtb {
11 
12  namespace graphics {
13 
14  class ShipShader: public Magnum::GL::AbstractShaderProgram {
15  public:
16  typedef Magnum::GL::Attribute<0, Vector3> Position;
17  typedef Magnum::GL::Attribute<1, Float> Wet;
18  typedef Magnum::GL::Attribute<2, Vector3> Normal;
19 
20  explicit ShipShader();
21 
22  ShipShader& setTransformationMatrix(const Magnum::Matrix4& matrix)
23  {
24  setUniform(_transformationMatrixUniform, matrix);
25  return *this;
26  }
27 
28  ShipShader& setProjectionMatrix(const Magnum::Matrix4& matrix)
29  {
30  setUniform(_projectionMatrixUniform, matrix);
31  return *this;
32  }
33 
34  ShipShader& setAmbientColor(const Color4& color) {
35  setUniform(_ambientColorUniform, color);
36  return *this;
37  }
38 
39  ShipShader& setDiffuseColor(const Color4& color) {
40  setUniform(_diffuseColorUniform, color);
41  return *this;
42  }
43 
44  ShipShader& setSpecularColor(const Color4& color) {
45  setUniform(_specularColorUniform, color);
46  return *this;
47  }
48 
49  ShipShader& setShininess(Float shininess) {
50  setUniform(_shininessUniform, shininess);
51  return *this;
52  }
53 
54  ShipShader& setTransparency(Float transparency) {
55  setUniform(_transparencyUniform, transparency);
56  return *this;
57  }
58 
59  ShipShader& setNormalMatrix(const Magnum::Matrix3& matrix) {
60  setUniform(_normalMatrixUniform, matrix);
61  return *this;
62  }
63 
64  ShipShader& setLightPosition(const Vector3& light) {
65  setUniform(_lightPositionUniform, light);
66  return *this;
67  }
68 
69  private:
70  Magnum::Int _transformationMatrixUniform{0},
71  _projectionMatrixUniform{1},
72  _normalMatrixUniform{2},
73  _lightPositionUniform{3},
74  _ambientColorUniform{4},
75  _diffuseColorUniform{5},
76  _specularColorUniform{6},
77  _shininessUniform{7},
78  _transparencyUniform{8};
79  };
80 
81  }
82 
83 }
84 
85 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9