YAGE  v0.1.1
Yet Another Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
glslprogram.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2  * glslprogram.h
3  *
4  * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
5  * See file LICENSE for more details
6  * ----------------------------------------------------------------------------
7  */
8 
9 #ifndef GLSL_PROGRAM_H
10 #define GLSL_PROGRAM_H
11 
12 #include <glad/glad.h>
13 
14 #include <string>
15 
16 namespace yage
17 {
18 
20 {
21 private:
23  GLuint program_id_ = 0;
24  GLuint vertex_shader_id_ = 0;
25  GLuint fragment_shader_id_ = 0;
27 
29  void compileShader(const GLuint &shader, const std::string &file_path);
30 
31 public:
32  GlslProgram() = default;
33  GlslProgram(const GlslProgram &) = delete;
34  GlslProgram(GlslProgram &&) = delete;
35  ~GlslProgram();
36 
37  GlslProgram &operator=(const GlslProgram &) = delete;
38  GlslProgram &operator=(GlslProgram &&) = delete;
39 
41  void compileShaders(const std::string &vertex_shader_path,
42  const std::string &fragment_shader_path);
43  void linkShaders();
44  void addAttribute(const std::string &attribute_name);
45  GLint getUniformLocation(const std::string &uniform_name);
46  void use();
47  void unuse();
48 };
49 
50 } // namespace yage
51 
52 #endif
void unuse()
Definition: glslprogram.cpp:154
int attribute_index_
Definition: glslprogram.h:26
Definition: glslprogram.h:19
void compileShaders(const std::string &vertex_shader_path, const std::string &fragment_shader_path)
compiles vertex and fragment shader
Definition: glslprogram.cpp:75
~GlslProgram()
Definition: glslprogram.cpp:18
GlslProgram()=default
GLuint program_id_
compiled shader program id
Definition: glslprogram.h:23
void linkShaders()
Definition: glslprogram.cpp:98
GLuint fragment_shader_id_
Definition: glslprogram.h:25
void addAttribute(const std::string &attribute_name)
Definition: glslprogram.cpp:131
void compileShader(const GLuint &shader, const std::string &file_path)
compiles one shader
Definition: glslprogram.cpp:34
void use()
Definition: glslprogram.cpp:146
GLuint vertex_shader_id_
Definition: glslprogram.h:24
GlslProgram & operator=(const GlslProgram &)=delete
GLint getUniformLocation(const std::string &uniform_name)
Definition: glslprogram.cpp:137