RenderEngine
Loading...
Searching...
No Matches
Shader.hpp
Go to the documentation of this file.
1/*
2 * Shader.hpp
3 *
4 * Class for representing shader implementation. Contains all the required function calls like create shaders, compile shaders.
5 * by Stefanie Zollmann
6 *
7 */
8
9#ifndef SHADER_HPP
10#define SHADER_HPP
11
12// Include standard headers
13#include <string>
14
15
16#include <glad/gl.h>
17
18#define GLAD_GL_IMPLEMENTATION
19#include <glm/glm.hpp>
20#include <glm/gtc/matrix_transform.hpp>
21
22
24
27class Shader{
28
29public:
31
33
34 }
36
38 Shader(std::string vertexshaderName, std::string fragmentshaderName){
39 initShaders(vertexshaderName,fragmentshaderName);
40
41 }
43
45 Shader(std::string shaderName){
46 initShaders(shaderName+".vert",shaderName+".frag");
47
48 }
49
51
53 virtual ~Shader();
54
56
57 GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path);
59
60 void initShaders(std::string vertexshaderName, std::string fragmentshaderName);
61
63
64 void updateMatrices(glm::mat4 MVP,glm::mat4 M,glm::mat4 V);
65
67
68 void updateMVP(glm::mat4 MVP);
69
71
72 virtual void bind();
73
74protected:
75 GLuint programID;
76 GLuint m_MVPID;
77 GLuint m_VID;
78 GLuint m_MID;
79};
80
81
82
83#endif
Shader.
Definition Shader.hpp:27
Shader()
Default constructor.
Definition Shader.hpp:32
void updateMatrices(glm::mat4 MVP, glm::mat4 M, glm::mat4 V)
updateMatrices
Definition Shader.cpp:123
Shader(std::string shaderName)
Constructor with shader source specification.
Definition Shader.hpp:45
Shader(std::string vertexshaderName, std::string fragmentshaderName)
Constructor with shader source specification.
Definition Shader.hpp:38
GLuint m_MVPID
all shader should get information about the MVP matrix
Definition Shader.hpp:76
GLuint m_MID
all shader should get information about the model matrix
Definition Shader.hpp:78
virtual void bind()
bind
Definition Shader.cpp:144
void initShaders(std::string vertexshaderName, std::string fragmentshaderName)
initShaders
Definition Shader.cpp:115
GLuint m_VID
all shader should get information about the view matrix
Definition Shader.hpp:77
void updateMVP(glm::mat4 MVP)
updateMVP
Definition Shader.cpp:132
GLuint LoadShaders(const char *vertex_file_path, const char *fragment_file_path)
LoadShaders.
Definition Shader.cpp:19
GLuint programID
Definition Shader.hpp:75
virtual ~Shader()
Destructor.
Definition Shader.cpp:138