SimpleGL  1.1.0
A framework for platform independent rendering
shader_objects.hpp
Go to the documentation of this file.
1 
8 #ifndef SHADER_OBJECTS_HPP
9 #define SHADER_OBJECTS_HPP
10 
11 #include <SimpleGL_gl/SimpleGL_gl_Export.h>
12 
13 #include <string>
14 
15 #include <GL/glew.h>
16 
17 #include <glm/glm.hpp>
18 
19 namespace sgl {
20 
26  enum class ShaderType : GLenum {
27 
29  VERTEX_SHADER = GL_VERTEX_SHADER,
30 
32  FRAGMENT_SHADER = GL_FRAGMENT_SHADER
33  };
34 
40  class SIMPLEGL_GL_EXPORT Shader {
41 
42  private:
44  GLuint handle;
45 
46  public:
52  Shader(ShaderType type);
53 
55  ~Shader(void);
56 
62  GLuint getHandle();
63 
69  void source(std::string source);
70 
72  void compile();
73 
79  bool getCompileStatus();
80 
86  std::string getInfoLog();
87  };
88 
93  class SIMPLEGL_GL_EXPORT ShaderProgram {
94 
95  private:
97  static ShaderProgram* current;
98 
100  GLuint handle;
101 
102  public:
104  ShaderProgram(void);
105 
107  ~ShaderProgram(void);
108 
114  GLuint getHandle();
115 
121  void attach(Shader* shader);
122 
124  void link();
125 
127  void use();
128 
134  bool getLinkStatus();
135 
141  std::string getInfoLog();
142 
149  void bindFragmentDataLocation(unsigned int colorNumber, std::string name);
150 
158  int getAttributeLocation(std::string name);
159 
167  int getUniformLocation(std::string name);
168 
175  void setUniform(int location, int value);
176 
183  void setUniform(int location, float value);
184 
191  void setUniform(int location, glm::vec2 value);
192 
199  void setUniform(int location, glm::vec3 value);
200 
207  void setUniform(int location, glm::vec4 value);
208 
215  void setUniform(int location, glm::mat2 value);
216 
223  void setUniform(int location, glm::mat3 value);
224 
231  void setUniform(int location, glm::mat4 value);
232 
239  void setUniform(std::string name, int value);
240 
247  void setUniform(std::string name, float value);
248 
255  void setUniform(std::string name, glm::vec2 value);
256 
263  void setUniform(std::string name, glm::vec3 value);
264 
271  void setUniform(std::string name, glm::vec4 value);
272 
279  void setUniform(std::string name, glm::mat2 value);
280 
287  void setUniform(std::string name, glm::mat3 value);
288 
295  void setUniform(std::string name, glm::mat4 value);
296  };
297 }
298 
299 #endif /* SHADER_OBJECTS_HPP */
This class wraps an OpenGL shader object.
ShaderType
This enum wraps the shader types.
Equivalent to GL_VERTEX_SHADER.
This class wraps an OpenGL shader program.
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
Equivalent to GL_FRAGMENT_SHADER.