blob: c1553208c15566a8d18f60df6f44aeb76269785b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#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;
}
}
|