40 lines
587 B
C++
40 lines
587 B
C++
|
#include "ShaderProgram.h"
|
||
|
|
||
|
ShaderProgram::ShaderProgram()
|
||
|
{
|
||
|
m_program = glCreateProgram();
|
||
|
m_vao = gen_vao();
|
||
|
}
|
||
|
|
||
|
ShaderProgram::~ShaderProgram()
|
||
|
{
|
||
|
glDeleteProgram(m_program);
|
||
|
}
|
||
|
|
||
|
void ShaderProgram::attach_shader(const Shader& shader)
|
||
|
{
|
||
|
glAttachShader(m_program, shader.get_shader());
|
||
|
}
|
||
|
|
||
|
void ShaderProgram::link()
|
||
|
{
|
||
|
glLinkProgram(m_program);
|
||
|
// TODO: Error handling
|
||
|
}
|
||
|
|
||
|
void ShaderProgram::use()
|
||
|
{
|
||
|
glUseProgram(m_program);
|
||
|
glBindVertexArray(get_vao());
|
||
|
}
|
||
|
|
||
|
GLuint ShaderProgram::get_program() const
|
||
|
{
|
||
|
return m_program;
|
||
|
}
|
||
|
|
||
|
GLuint ShaderProgram::get_vao() const
|
||
|
{
|
||
|
return m_vao;
|
||
|
}
|