-
Notifications
You must be signed in to change notification settings - Fork 0
/
shader.cpp
37 lines (31 loc) · 837 Bytes
/
shader.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
#include <GL/glew.h>
#include "shader.h"
Shader::Shader(char* source, GLenum shaderType) {
int status;
name = glCreateShader(shaderType);
glShaderSource(name, 1, (const GLchar**)&source, 0);
glCompileShader(name);
glGetShaderiv(name, GL_COMPILE_STATUS, &status);
if (status != GL_TRUE) {
printf("something bad went wrong!!!!\n");
}
}
ShaderProgram::ShaderProgram(const Shader &s) {
int status;
program = glCreateProgram();
glAttachShader(program, s.name);
glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &status);
if (status != GL_TRUE) {
printf("something else bad went wrong!!!!\n");
}
}
void ShaderProgram::enable() {
glUseProgram(program);
}
void ShaderProgram::disable() {
glUseProgram(0);
}
GLint ShaderProgram::uniformLocation(char* name) {
return glGetUniformLocation(program, name);
}