aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mgl/graphics/shader.h2
-rw-r--r--src/graphics/shader.c5
-rw-r--r--src/graphics/vertex.c5
3 files changed, 12 insertions, 0 deletions
diff --git a/include/mgl/graphics/shader.h b/include/mgl/graphics/shader.h
index 16b573a..19d0605 100644
--- a/include/mgl/graphics/shader.h
+++ b/include/mgl/graphics/shader.h
@@ -2,6 +2,7 @@
#define MGL_SHADER_H
#include "../system/vec.h"
+#include "../graphics/color.h"
typedef struct mgl_texture mgl_texture;
@@ -26,6 +27,7 @@ int mgl_shader_program_set_uniform_float(mgl_shader_program *self, const char *u
int mgl_shader_program_set_uniform_vec2f(mgl_shader_program *self, const char *uniform_name, mgl_vec2f value);
int mgl_shader_program_set_uniform_vec3f(mgl_shader_program *self, const char *uniform_name, mgl_vec3f value);
int mgl_shader_program_set_uniform_vec4f(mgl_shader_program *self, const char *uniform_name, mgl_vec4f value);
+int mgl_shader_program_set_uniform_color(mgl_shader_program *self, const char *uniform_name, mgl_color color);
/* If |shader_program| is NULL then no shader is used */
void mgl_shader_program_use(mgl_shader_program *shader_program);
diff --git a/src/graphics/shader.c b/src/graphics/shader.c
index f7f5545..f362490 100644
--- a/src/graphics/shader.c
+++ b/src/graphics/shader.c
@@ -231,6 +231,11 @@ int mgl_shader_program_set_uniform_vec4f(mgl_shader_program *self, const char *u
return 0;
}
+int mgl_shader_program_set_uniform_color(mgl_shader_program *self, const char *uniform_name, mgl_color color) {
+ return mgl_shader_program_set_uniform_vec4f(self, uniform_name,
+ (mgl_vec4f){ color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f });
+}
+
/* TODO: Optimize glUseProgram */
void mgl_shader_program_use(mgl_shader_program *shader_program) {
mgl_context *context = mgl_get_context();
diff --git a/src/graphics/vertex.c b/src/graphics/vertex.c
index e55c180..92a6e93 100644
--- a/src/graphics/vertex.c
+++ b/src/graphics/vertex.c
@@ -1,11 +1,14 @@
#include "../../include/mgl/graphics/vertex.h"
#include "../../include/mgl/graphics/texture.h"
+#include "../../include/mgl/window/window.h"
#include "../../include/mgl/mgl.h"
void mgl_vertices_draw(mgl_context *context, const mgl_vertex *vertices, size_t vertex_count, mgl_primitive_type primitive_type, mgl_vec2f position) {
if(vertex_count == 0)
return;
+ mgl_window_set_texture_blend_func(context->current_window);
+
context->gl.glPushMatrix();
if(!mgl_texture_current_texture()) {
@@ -22,4 +25,6 @@ void mgl_vertices_draw(mgl_context *context, const mgl_vertex *vertices, size_t
context->gl.glDrawArrays(mgl_primitive_type_to_gl_mode(primitive_type), 0, vertex_count);
context->gl.glPopMatrix();
+
+ mgl_window_set_render_blend_func(context->current_window);
}