blob: 34979a1193b48049355fbacdfbf56dae89cbb7d4 (
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
|
#include "shader.h"
namespace gfx {
Shader::Shader(const std::string& text, int type) {
_shader_id = glCreateShader(type);
int len = text.length();
const char* txt = text.c_str();
glShaderSource(_shader_id, 1, &txt, &len);
glCompileShader(_shader_id);
}
Shader::Shader(Shader&& other) : _shader_id(other._shader_id) {
other._shader_id = 0;
}
Shader::~Shader() {
if (!_shader_id)
return;
// Delete the shader
glDeleteShader(_shader_id);
}
GLuint Shader::shader_id() {
return _shader_id;
}
}
|