charcoal/OpenGLEngine/ShaderProgram.cpp

34 lines
529 B
C++
Raw Normal View History

2018-09-05 06:49:02 +00:00
#include "ShaderProgram.h"
2018-09-12 21:03:46 +00:00
namespace charcoal
2018-09-05 06:49:02 +00:00
{
2018-09-12 21:03:46 +00:00
ShaderProgram::ShaderProgram()
: m_program(glCreateProgram())
{}
2018-09-05 06:49:02 +00:00
2018-09-12 21:03:46 +00:00
ShaderProgram::~ShaderProgram()
{
glDeleteProgram(m_program);
}
2018-09-05 06:49:02 +00:00
2018-09-12 21:03:46 +00:00
void ShaderProgram::attach_shader(const Shader& shader)
{
glAttachShader(m_program, shader.get_shader());
}
2018-09-05 06:49:02 +00:00
2018-09-12 21:03:46 +00:00
void ShaderProgram::link()
{
glLinkProgram(m_program);
// TODO: Error handling
}
2018-09-05 06:49:02 +00:00
2018-09-12 21:03:46 +00:00
void ShaderProgram::use() const
{
glUseProgram(m_program);
}
GLuint ShaderProgram::get_program() const
{
return m_program;
}
}