summary refs log tree commit diff
path: root/src/Shader/Shader.cpp
blob: 0cd6ab36fd86994a5ac6a682ff78b36b9170d09e (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
#include <GL/glew.h>
#include <stdexcept>
#include "Shader.hpp"

namespace MC {

Shader::Shader(uint32_t type, const char* source) {
    m_shader = glCreateShader(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);
    }
}


}