charcoal/OpenGLEngine/ShaderProgram.cpp
elipzer 9920dfc25b Added Diffuse Light to LitScene
YES! FINALLY LIGHTING! Next up is specular light!
2018-09-14 21:29:05 -04:00

48 lines
972 B
C++

#include "ShaderProgram.h"
namespace charcoal
{
ShaderProgram::ShaderProgram()
: m_program(glCreateProgram())
{}
ShaderProgram::~ShaderProgram()
{
glDeleteProgram(m_program);
}
void ShaderProgram::attach_shader(const Shader& shader)
{
glAttachShader(m_program, shader.get_shader());
}
void ShaderProgram::link()
{
glLinkProgram(m_program);
GLint program_linked;
glGetProgramiv(m_program, GL_LINK_STATUS, &program_linked);
if (program_linked != GL_TRUE)
{
GLsizei log_length = 0;
GLchar message[1024];
glGetProgramInfoLog(m_program, 1023, &log_length, message);
message[log_length] = '\0'; // Add null terminator
OutputDebugString("Error Linking Shader Program:\n");
OutputDebugString(message);
OutputDebugString("\n");
throw EXCEPTION("Error linking Shader Program.");
}
}
void ShaderProgram::use() const
{
glUseProgram(m_program);
}
GLuint ShaderProgram::get_program() const
{
return m_program;
}
}