-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShaderProgram.h
More file actions
44 lines (34 loc) · 1.06 KB
/
ShaderProgram.h
File metadata and controls
44 lines (34 loc) · 1.06 KB
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
#ifndef SHADER_PROGRAM
#define SHADER_PROGRAM
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <string>
class ShaderProgram
{
public:
ShaderProgram() {}
~ShaderProgram() {}
void init(const std::string& vertexFile, const std::string& fragmentFile);
void start();
void stop();
void cleanUp();
std::string getVertexFile() const { return VERTEX_FILE; }
std::string getFragmentFile() const { return FRAGMENT_FILE; }
protected:
GLuint getUniformLocation(std::string name);
void bindAttribute(int attrib, std::string name);
void loadBool(int location, bool val);
void loadInt(int location, int val);
void loadFloat(int location, float val);
void loadVector3f(int location, glm::vec3 vec);
void loadVector4f(int location, glm::vec4 vec);
void loadMatrix4f(int location, glm::mat4 matrix);
virtual void bindAttributes() = 0;
virtual void getUniformLocations() = 0;
std::string VERTEX_FILE, FRAGMENT_FILE;
private:
GLuint _programID;
GLuint _vertexShaderID, _fragmentShaderID;
GLuint loadShader(const std::string& file, GLuint type);
};
#endif //SHADER_PROGRAM