#include "gfx.h" #include "program.h" namespace gfx { Program::Program() { _program_id = glCreateProgram(); } Program::Program(Program&& other) : _program_id(other._program_id) { other._program_id = 0; } Program::~Program() { if (!_program_id) return; // Delete the program glDeleteProgram(_program_id); } void Program::attach(Shader& shader) { glAttachShader(_program_id, shader.shader_id()); } void Program::link() { glLinkProgram(_program_id); } void Program::use() { if (state::current_program_id == _program_id) return; glUseProgram(_program_id); state::current_program_id = _program_id; } GLuint Program::program_id() { return _program_id; } }