-
Notifications
You must be signed in to change notification settings - Fork 0
/
IGLSLShader.h
46 lines (34 loc) · 1.07 KB
/
IGLSLShader.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
41
42
43
44
45
46
#ifndef _TINY_PIYO_GLSLPROGRAM_H
#define _TINY_PIYO_GLSLPROGRAM_H
#include "GL/glew.h"
#include <glm/gtc/matrix_transform.hpp>
#include <string>
struct ShaderProgramSource
{
std::string VertexSource;
std::string FragmentSource;
};
enum class ShaderType
{
NONE = -1,
VERTEX = 0,
FRAGMENT = 1
};
ShaderProgramSource ParseShader(const std::string& filepath);
unsigned int CompileShader(unsigned int type, const std::string& source);
unsigned int CreateShader(const std::string& vertexShader, const std::string& fragmentShader);
class IGLSLShader
{
public:
~IGLSLShader();
void Use() { glUseProgram(this->_programID); };
void Unuse() { glUseProgram(0); };
unsigned int GetUniformLocation(const std::string& name);
void UniformMatrix4fv(const std::string& name, glm::mat4& value);
void UniformBool(const std::string& name, bool value);
void UniformInt(const std::string& name, int value);
void UniformFloat(const std::string& name, float value);
protected:
unsigned int _programID;
};
#endif