Implemented shader program headers
This commit is contained in:
0
src/inc/program.cpp
Normal file
0
src/inc/program.cpp
Normal file
43
src/inc/program.hpp
Normal file
43
src/inc/program.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// 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;
|
||||
}
|
||||
@@ -14,4 +14,7 @@
|
||||
#include <SDL.h>
|
||||
|
||||
#include <shader.hpp>
|
||||
#include <shader.cpp>
|
||||
#include <shader.cpp>
|
||||
|
||||
#include <program.hpp>
|
||||
#include <program.cpp>
|
||||
Reference in New Issue
Block a user