-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShader.h
40 lines (24 loc) · 975 Bytes
/
Shader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef LEARNINGOPENGL_SHADER_H
#define LEARNINGOPENGL_SHADER_H
#include <string>
#include <glad/glad.h>
#include <glm/glm.hpp>
class Shader {
public:
Shader();
bool compileAndLink(const std::string &vertexShaderPath, const std::string &fragmentShaderPath);
void use() const;
void setInteger(const std::string &name, int value) const;
void setFloat(const std::string &name, float value) const;
void setVector3(const std::string &name, const glm::vec3 &vector) const;
void setMatrix3(const std::string &name, const glm::mat3 &matrix) const;
void setMatrix4(const std::string &name, const glm::mat4 &matrix) const;
void dispose();
private:
static bool readFile(const std::string &shaderPath, std::string &shaderCode);
static bool compileShader(const std::string &shaderPath, GLenum shaderType, unsigned int &shader);
void destroy();
unsigned int handle;
bool isLinked;
};
#endif //LEARNINGOPENGL_SHADER_H