aboutsummaryrefslogtreecommitdiff
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/shader.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/graphics/shader.c b/src/graphics/shader.c
index 83c8407..f7f5545 100644
--- a/src/graphics/shader.c
+++ b/src/graphics/shader.c
@@ -203,6 +203,34 @@ int mgl_shader_program_set_uniform_vec2f(mgl_shader_program *self, const char *u
return 0;
}
+int mgl_shader_program_set_uniform_vec3f(mgl_shader_program *self, const char *uniform_name, mgl_vec3f value) {
+ mgl_context *context = mgl_get_context();
+ int uniform_location = context->gl.glGetUniformLocation(self->id, uniform_name);
+ if(uniform_location == -1) {
+ fprintf(stderr, "mgl error: no uniform by the name %s was found in the shader\n", uniform_name);
+ return -1;
+ }
+
+ context->gl.glUseProgram(self->id);
+ context->gl.glUniform3f(uniform_location, value.x, value.y, value.z);
+ context->gl.glUseProgram(0);
+ return 0;
+}
+
+int mgl_shader_program_set_uniform_vec4f(mgl_shader_program *self, const char *uniform_name, mgl_vec4f value) {
+ mgl_context *context = mgl_get_context();
+ int uniform_location = context->gl.glGetUniformLocation(self->id, uniform_name);
+ if(uniform_location == -1) {
+ fprintf(stderr, "mgl error: no uniform by the name %s was found in the shader\n", uniform_name);
+ return -1;
+ }
+
+ context->gl.glUseProgram(self->id);
+ context->gl.glUniform4f(uniform_location, value.x, value.y, value.z, value.w);
+ context->gl.glUseProgram(0);
+ return 0;
+}
+
/* TODO: Optimize glUseProgram */
void mgl_shader_program_use(mgl_shader_program *shader_program) {
mgl_context *context = mgl_get_context();