-
Notifications
You must be signed in to change notification settings - Fork 0
/
GLSL.h
87 lines (64 loc) · 1.59 KB
/
GLSL.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include <GL\glew.h>
#include <fstream>
#include <iostream>
#include <vector>
#include <glm\glm.hpp>
#include <glm\gtc\type_ptr.hpp>
enum shaderType
{
GLSL_VERTEX_SHADER,
GLSL_FRAGMENT_SHADER,
GLSL_GEOMETRY_SHADER,
//other shader types
};
class GLSLShader
{
private:
shaderType type;
unsigned int handle;
public:
//Constructors
GLSLShader(void);
//Destructor
~GLSLShader(void);
//getters
inline shaderType GetType(void) { return type; }
inline unsigned int GetHandle(void) { return handle; }
//remove from graphics memory
void Release(void);
//Create the file based on either a string or a file
int CreateShaderFromFile(shaderType newType, const char *filePath);
int CreateShaderFromString(shaderType newType, const char *string);
};
class GLSLProgram
{
private:
unsigned int handle;
public:
//Getters
inline unsigned int GetHandle(void) { return handle; }
//Constructors
GLSLProgram(void);
//Destructor
~GLSLProgram(void);
//Remove from graphics memory
void Release(void);
//Attach a shader to the program
//returns 0 if not attached, 1 if attached
int AttachShader(GLSLShader *shader);
//Link the shader
int LinkProgram(void);
//
int ValidateProgram(void);
//Activate the program for use in application
void Activate(void);
//Deactivate
static void Deactivate(void);
//
int GetUniformLocation(const char *uniformName);
//
static void UniformFloat(int location, const float value);
void UniformMat4(int location, bool transpose, const glm::mat4 value);
//void UniformVec3List(int location, unsigned int numValues, const glm::vec3 *valueList);
};