blob: 6dfac34bba3c1856c28941e451fabc8508c12da9 (
plain)
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
|
#include <GL/glew.h>
#include <stdexcept>
#include "Shader.hpp"
namespace MC::GFX::Shading {
Shader::Shader(Type type, const char* source) {
uint32_t gl_type = 0;
switch (type) {
case Type::Vertex:
gl_type = GL_VERTEX_SHADER;
break;
case Type::Fragment:
gl_type = GL_FRAGMENT_SHADER;
break;
}
m_shader = glCreateShader(gl_type);
glShaderSource(m_shader, 1, &source, nullptr);
glCompileShader(m_shader);
GLint success;
glGetShaderiv(m_shader, GL_COMPILE_STATUS, &success);
if(!success) {
char message[512] = {};
glGetShaderInfoLog(m_shader, 512, nullptr, message);
throw std::runtime_error(message);
}
}
}
|