blob: 5f68bc6ce50edb9d49da18877dfc78d6b8230292 (
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 "../../../include/RenderBackend/OpenGL/Uniform.hpp"
#include "../../../include/RenderBackend/OpenGL/opengl.hpp"
namespace amalgine {
Uniform::~Uniform() {}
void Uniform::set(float value) {
use();
glUniform1f(uniform_id, value);
}
void Uniform::set(const vec3f &value) {
use();
glUniform3f(uniform_id, value.x, value.y, value.z);
}
void Uniform::set(const glm::mat4 &value) {
use();
glUniformMatrix4fv(uniform_id, 1, GL_FALSE, glm::value_ptr(value));
}
void Uniform::set(const Texture2D &texture) {
use();
glUniform1i(uniform_id, texture.get_texture_id());
}
Uniform::Uniform(i32 uniform_id, u32 shader_program_id) : uniform_id(uniform_id), program_id(shader_program_id) {
}
void Uniform::use() {
glUseProgram(program_id);
}
}
|