forked from fede-vaccaro/TerrainEngine-OpenGL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshader.h
34 lines (29 loc) · 1.08 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
#pragma once
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
class Shader
{
public:
unsigned int ID;
Shader(const char* vertexPath, const char* fragmentPath);
virtual ~Shader();
void use();
void setBool(const std::string &name, bool value) const;
void setInt(const std::string &name, int value) const;
void setFloat(const std::string &name, float value) const;
void setVec2(const std::string &name, glm::vec2 vector) const;
void setVec3(const std::string &name, glm::vec3 vector) const;
void setVec4(const std::string &name, glm::vec4 vector) const;
void setMat4(const std::string &name, glm::mat4 matrix) const;
void setSampler2D(const std::string &name, unsigned int texture, int id) const;
void setSampler3D(const std::string &name, unsigned int texture, int id) const;
protected:
void checkCompileErrors(unsigned int shader, std::string type, std::string shaderName);
std::string getShaderName(const char* shaderPath);
std::string loadShaderFromFile(const char* shaderPath);
};