diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-11-05 21:38:20 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-11-05 21:38:20 +0100 |
commit | e2e7c0bf0747d55967c4be6374f3611cd96babb6 (patch) | |
tree | 7267f2086526ac780f57998ff93bae72266e8ddb /src/graphics/shader.c | |
parent | ccb3e58071b3e807109918184727b305df8b96a0 (diff) |
Add bounds calculation to text
Diffstat (limited to 'src/graphics/shader.c')
-rw-r--r-- | src/graphics/shader.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/graphics/shader.c b/src/graphics/shader.c index 9afde0e..8f44f0f 100644 --- a/src/graphics/shader.c +++ b/src/graphics/shader.c @@ -173,6 +173,21 @@ int mgl_shader_program_finalize(mgl_shader_program *self) { /* TODO: Optimize glUseProgram */ /* TODO: Optimize glGetUniformLocation */ +/* TODO: Check if the uniform type matches the type of the value we want to set it to */ + +int mgl_shader_program_set_uniform_float(mgl_shader_program *self, const char *uniform_name, float value) { + mgl_context *context = mgl_get_context(); + int uniform_location = context->gl.glGetUniformLocation(self->id, uniform_name); + if(uniform_location == -1) { + fprintf(stderr, "Error: no uniform by the name %s was found in the shader\n", uniform_name); + return -1; + } + + context->gl.glUseProgram(self->id); + context->gl.glUniform1f(uniform_location, value); + context->gl.glUseProgram(0); + return 0; +} int mgl_shader_program_set_uniform_vec2f(mgl_shader_program *self, const char *uniform_name, mgl_vec2f value) { mgl_context *context = mgl_get_context(); @@ -183,7 +198,7 @@ int mgl_shader_program_set_uniform_vec2f(mgl_shader_program *self, const char *u } context->gl.glUseProgram(self->id); - context->gl.glUniform2fv(uniform_location, 1, &value.x); + context->gl.glUniform2f(uniform_location, value.x, value.y); context->gl.glUseProgram(0); return 0; } |