Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shader.h
Go to the documentation of this file.
1 #ifndef SHADER_H
2 #define SHADER_H
3 #include <map>
4 #include <string>
5 #ifdef __APPLE__
6 #include <OpenGL/gl3.h>
7 #else
8 #include <GL/glew.h>
9 #endif
10 #include "uniform.h"
11 //= SCRIPTABLE
12 
13 namespace Graphics {
17  class Shader {
18  private:
19  unsigned int program_object;
20  std::map<std::string, int> name_to_location;
21  std::map<std::string, GLenum> name_to_type;
22  std::string name;
23  public:
24  Shader() = delete;
32  Shader(const unsigned int vertex_program, const unsigned int fragment_program, const unsigned int geometry_program = 0);
33 
39  unsigned int getHandle() const noexcept;
43  void useProgram() const;
44 
45  //= BEGIN SCRIPTABLE
46 
52  std::vector<std::string> getUniformNames() const noexcept;
58  void setUniform(const Uniform& uniform);
64  void setName(const std::string& name);
70  std::string getName() const noexcept;
76  std::string to_string() const noexcept;
77  //= END SCRIPTABLE
78 
87  template<class T>
88  void setUniform(const std::string& name, const T& value);
89  };
90 }
91 
92 #endif
Class for shader.
Definition: shader.h:17
std::vector< std::string > getUniformNames() const noexcept
Gets the uniform names.
Definition: shader.cpp:74
Class for shader uniform.
Definition: uniform.h:10
void setUniform(const Uniform &uniform)
Sets the uniform.
Definition: shader.cpp:411
void setName(const std::string &name)
Sets the name.
Definition: shader.cpp:493
std::string to_string() const noexcept
Returns a string representation of the object.
Definition: shader.cpp:500
unsigned int getHandle() const noexcept
Gets the shader's opengl handle.
Definition: shader.cpp:63
void useProgram() const
Tell open gl to use this shader.
Definition: shader.cpp:67
std::string getName() const noexcept
Gets the name.
Definition: shader.cpp:497