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 
10 #pragma once
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(std::string const &vertex_path, std::string const &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(std::string const &name, int value) const;
36  void setUniform(std::string const &name, float value) const;
37  void setUniform(std::string const &name, const glm::mat4 &matrix) const;
38 
39 private:
41  GLuint program_id_ = 0;
42 
43  GLint getUniformLocation(std::string const &uniform_name) const;
44  void errorCheck(GLuint shader, std::string const &shader_type) const;
45 };
46 
47 } // namespace yage
Shader & operator=(const Shader &)=delete
Definition: shader.h:20
void setUniform(std::string const &name, int value) const
set uniforms of different type
Definition: shader.cpp:88
~Shader()
Definition: shader.cpp:75
void use() const
compiles vertex and fragment shader
Definition: shader.cpp:83
Shader(std::string const &vertex_path, std::string const &fragment_path)
Definition: shader.cpp:23