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>
5  * MIT License, see LICENSE file 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 public:
22  GlslProgram() = default;
23  GlslProgram(const GlslProgram &) = delete;
24  GlslProgram(GlslProgram &&) = delete;
25  ~GlslProgram();
26 
27  GlslProgram &operator=(const GlslProgram &) = delete;
28  GlslProgram &operator=(GlslProgram &&) = delete;
29 
31  void compileShaders(const std::string &vertex_shader_path,
32  const std::string &fragment_shader_path);
33  void linkShaders();
34  void addAttribute(const std::string &attribute_name);
35  GLint getUniformLocation(const std::string &uniform_name);
36  void use();
37  void unuse();
38 
39  void defaultSetup();
40 
41 private:
43  GLuint program_id_ = 0;
44  GLuint vertex_shader_id_ = 0;
45  GLuint fragment_shader_id_ = 0;
47 
49  void compileShader(const GLuint &shader, const std::string &file_path);
50 };
51 
52 } // namespace yage
53 
54 #endif
void unuse()
Definition: glslprogram.cpp:154
int attribute_index_
Definition: glslprogram.h:46
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:43
void defaultSetup()
Definition: glslprogram.cpp:162
void linkShaders()
Definition: glslprogram.cpp:98
GLuint fragment_shader_id_
Definition: glslprogram.h:45
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:44
GlslProgram & operator=(const GlslProgram &)=delete
GLint getUniformLocation(const std::string &uniform_name)
Definition: glslprogram.cpp:137