-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShaderProgram.h
60 lines (50 loc) · 1.41 KB
/
ShaderProgram.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
#ifndef SHADERPROGRAM_H
#define SHADERPROGRAM_H
#include "Color.h"
#include "Vector.h"
#include "Matrix.h"
#include <iostream>
#include <fstream>
#include <streambuf>
#include <vector>
#ifdef WIN32
#include <windows.h>
#include <GL/glew.h>
#include <GL/GLUT.h>
#include <GL/GL.h>
#elif __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/GLUT.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif
using namespace std;
class ShaderProgram{
public:
ShaderProgram();
~ShaderProgram();
bool load(const char* VertexShader, const char* FragmentShader);
bool loadVertexShader(const char* VertexShader);
bool loadFragmentShader(const char* FragmentShader);
bool compile(string* CompileErrors=nullptr);
GLint getParameterID(const char* ParameterName) const;
void setParameter( GLint ID, float param) const;
void setParameter( GLint ID, int param) const;
void setParameter( GLint ID, const Vector& param)const;
void setParameter( GLint ID, const Color& param) const;
void setParameter( GLint ID, const Matrix& param)const;
void activate() const;
void deactivate() const;
// Custom functionss
bool compileShader(GLuint shader, string *errorMessage);
bool hasLinked(GLuint program);
GLuint getId() const;
private:
GLuint m_VertexShader;
GLuint m_FragmentShader;
GLuint m_ShaderProgram;
bool vLoaded = false;
bool fLoaded = false;
};
#endif