-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shader.h
35 lines (30 loc) · 1.19 KB
/
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
#pragma once
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <string>
#include <fstream>
class Shader {
public:
GLuint program = -1;
Shader();
Shader(std::string vertexShaderPath, std::string fragmentShaderPath);
void use() const;
void reload();
void setFloat(std::string name, GLfloat value);
void setInteger(std::string name, GLint value);
void setVector2f(std::string name, GLfloat x, GLfloat y);
void setVector2f(std::string name, glm::vec2 value);
void setVector3f(std::string name, GLfloat x, GLfloat y, GLfloat z);
void setVector3f(std::string name, glm::vec3 value) const;
void setMatrix4(std::string name, const glm::mat4 &value) const;
void setTexture2D(std::string name, GLenum activeTexture, GLuint texture, GLuint loc);
void setTextureCubeMap(std::string name, GLenum activeTexture, GLuint texture, GLuint loc);
private:
GLuint loadShader(GLuint shaderType, std::string shaderCode);
void compileShader(std::string vertexShaderPath, std::string fragmentShaderPath);
std::string vertexShaderPath;
std::string fragmentShaderPath;
};