-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShader.cpp
More file actions
33 lines (29 loc) · 920 Bytes
/
Shader.cpp
File metadata and controls
33 lines (29 loc) · 920 Bytes
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
#include <iostream>
#include "Shader.h"
#include <GL/glew.h>
namespace MAGE {
bool Shader::AddComponent(unsigned int type, char *source) {
int shaderId = glCreateShader(type);
glShaderSource(shaderId, 1, &source, nullptr);
glCompileShader(shaderId);
int success;
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success);
if (!success) {
int length;
glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &length);
char message[length];
glGetShaderInfoLog(shaderId, length, &length, message);
std::cout << "Shader Error [" << type << "]: " << message << std::endl;
return -1;
};
glAttachShader(ID, shaderId);
glDeleteShader(shaderId);
return 0;
}
void Shader::Compile() {
glLinkProgram(ID);
}
Shader::Shader() {
ID = glCreateProgram();
}
}