diff --git a/src/inc/program.cpp b/src/inc/program.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/inc/program.hpp b/src/inc/program.hpp new file mode 100644 index 0000000..db619d4 --- /dev/null +++ b/src/inc/program.hpp @@ -0,0 +1,43 @@ +#include +#include + +// Load a shader program from two files. One is a vertex shader, and one is a +// fragment shader. Geometry shader support is not implemented. + +GLuint mc_load_program(std::string vertex_path, std::string fragment_path) +{ + GLuint shader_program = glCreateProgram(); + + GLuint vertex_shader = mcu_load_shader(vertex_path, GL_VERTEX_SHADER); + + GLuint fragment_shader = mcu_load_shader(fragment_path, GL_FRAGMENT_SHADER); + + glAttachShader(shader_program, vertex_shader); + + glAttachShader(shader_program, fragment_shader); + + glLinkProgram(shader_program); + + GLint success = 0; + + glGetProgramiv(shader_program, GL_LINK_STATUS, &success); + + if (!success) + { + std::cout << "Could not link shader program loaded from \"" << vertex_path << "\" and \"" << fragment_path << "\"." << std::endl; + + GLchar crash_information[4096]; + + glGetProgramInfoLog(shader_program, 4096, NULL, crash_information); + + std::cout << crash_information; + + exit(10); + } + + glDeleteShader(vertex_shader); + + glDeleteShader(fragment_shader); + + return shader_program; +} \ No newline at end of file diff --git a/src/main.hpp b/src/main.hpp index 0cf79be..c34880b 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -14,4 +14,7 @@ #include #include -#include \ No newline at end of file +#include + +#include +#include \ No newline at end of file