aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/shader_program.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/shader_program.c b/src/core/shader_program.c
index eeb46f8..3840019 100644
--- a/src/core/shader_program.c
+++ b/src/core/shader_program.c
@@ -209,6 +209,35 @@ static ShaderUniform* get_or_allocate_uniform(
209// The functions below save the value of a uniform in the shader program. If the 209// The functions below save the value of a uniform in the shader program. If the
210// uniform does not even exist, then there is no need to store the value. 210// uniform does not even exist, then there is no need to store the value.
211 211
212void gfx_set_uniform(ShaderProgram* prog, const ShaderUniform* uniform) {
213 switch (uniform->type) {
214 case UniformInt:
215 gfx_set_int_uniform(prog, uniform->name.str, uniform->value.uniform_int);
216 break;
217 case UniformFloat:
218 gfx_set_float_uniform(
219 prog, uniform->name.str, uniform->value.uniform_float);
220 break;
221 case UniformMat4:
222 gfx_set_mat4_uniform(prog, uniform->name.str, &uniform->value.uniform_mat4);
223 break;
224 case UniformVec3:
225 gfx_set_vec3_uniform(prog, uniform->name.str, uniform->value.uniform_vec3);
226 break;
227 case UniformVec4:
228 gfx_set_vec4_uniform(prog, uniform->name.str, uniform->value.uniform_vec4);
229 break;
230 case UniformTexture:
231 gfx_set_texture_uniform(prog, uniform->name.str, uniform->value.texture);
232 break;
233 case UniformMat4Array:
234 gfx_set_mat4_array_uniform(
235 prog, uniform->name.str, uniform->value.array.values,
236 uniform->value.array.count);
237 break;
238 }
239}
240
212void gfx_set_int_uniform(ShaderProgram* prog, const char* name, int value) { 241void gfx_set_int_uniform(ShaderProgram* prog, const char* name, int value) {
213 assert(prog); 242 assert(prog);
214 assert(name); 243 assert(name);