/
ShaderProgram.cpp
39 lines (31 loc) · 1.25 KB
/
ShaderProgram.cpp
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
#include "framework.h"
#include <glload/gl_3_3.h>
#include "ShaderProgram.h"
ShaderProgram::ShaderProgram(const std::string& vertexShaderName, const std::string& fragmentShaderName) {
vertexShader = new Shader(GL_VERTEX_SHADER, vertexShaderName);
fragmentShader = new Shader(GL_FRAGMENT_SHADER, fragmentShaderName);
shaderList.push_back(vertexShader->getShader());
shaderList.push_back(fragmentShader->getShader());
theProgram = Framework::CreateProgram(shaderList);
modelToWorldMatrixUnif = glGetUniformLocation(theProgram, "modelToWorldMatrix");
globalUniformBlockIndex = glGetUniformBlockIndex(theProgram, "GlobalMatrices");
baseColorUnif = glGetUniformLocation(theProgram, "baseColor");
glUniformBlockBinding(theProgram, globalUniformBlockIndex, globalMatricesBindingIndex);
}
ShaderProgram::~ShaderProgram(void) {
}
GLuint ShaderProgram::getProgram() {
return theProgram;
}
GLuint ShaderProgram::getGlobalUniformBlockIndex() {
return globalUniformBlockIndex;
}
GLuint ShaderProgram::getModelToWorldMatrixUnif() {
return modelToWorldMatrixUnif;
}
GLuint ShaderProgram::getBaseColorUnif() {
return baseColorUnif;
}
int ShaderProgram::getGlobalMatricesBindingIndex() {
return globalMatricesBindingIndex;
}