Yet Another Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shader.h
Go to the documentation of this file.
1 
9 #ifndef YAGE_RENDER_SHADER_H
10 #define YAGE_RENDER_SHADER_H
11 
12 #include <glad/glad.h>
13 #include <glm/glm.hpp>
14 
15 #include <string>
16 
17 namespace yage
18 {
19 
20 class Shader
21 {
22 public:
23  Shader(const std::string &vertex_path, const std::string &fragment_path);
24  Shader(const Shader &) = delete;
25  Shader(Shader &&) = delete;
26  ~Shader();
27 
28  Shader &operator=(const Shader &) = delete;
29  Shader &operator=(Shader &&) = delete;
30 
32  void use() const;
33 
35  void setUniform(const std::string &name, int value) const;
36  void setUniform(const std::string &name, float value) const;
37  void setUniform(const std::string &name, const glm::mat4 &matrix) const;
38 
39 private:
41  GLuint program_id_ = 0;
42 
43  GLint getUniformLocation(const std::string &uniform_name) const;
44  void errorCheck(GLuint shader, const std::string &shader_type) const;
45 };
46 
47 } // namespace yage
48 
49 #endif
Shader & operator=(const Shader &)=delete
Shader(const std::string &vertex_path, const std::string &fragment_path)
Definition: shader.cpp:22
void setUniform(const std::string &name, int value) const
set uniforms of different type
Definition: shader.cpp:87
Definition: shader.h:20
~Shader()
Definition: shader.cpp:74
void use() const
compiles vertex and fragment shader
Definition: shader.cpp:82