From f2da59054cedd1c07779e72537da4d7b14616b48 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Aug 2024 06:01:36 +0200 Subject: Ensure correct blending function for transparent window --- src/graphics/sprite.c | 5 +++++ src/graphics/text.c | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'src/graphics') diff --git a/src/graphics/sprite.c b/src/graphics/sprite.c index 3110cf9..613ec4c 100644 --- a/src/graphics/sprite.c +++ b/src/graphics/sprite.c @@ -1,5 +1,6 @@ #include "../../include/mgl/graphics/sprite.h" #include "../../include/mgl/graphics/texture.h" +#include "../../include/mgl/window/window.h" #include "../../include/mgl/mgl.h" void mgl_sprite_init(mgl_sprite *self, mgl_texture *texture) { @@ -60,6 +61,8 @@ void mgl_sprite_draw(mgl_context *context, mgl_sprite *sprite) { if(!sprite->texture) return; + mgl_window_set_texture_blend_func(context->current_window); + float texture_right = 1.0f; float texture_bottom = 1.0f; if(sprite->texture->pixel_coordinates) { @@ -86,4 +89,6 @@ void mgl_sprite_draw(mgl_context *context, mgl_sprite *sprite) { context->gl.glEnd(); mgl_texture_use(NULL); context->gl.glLoadIdentity(); /* TODO: Remove, but what about glRotatef above */ + + mgl_window_set_render_blend_func(context->current_window); } diff --git a/src/graphics/text.c b/src/graphics/text.c index 0942b62..76ac128 100644 --- a/src/graphics/text.c +++ b/src/graphics/text.c @@ -1,6 +1,7 @@ #include "../../include/mgl/graphics/text.h" #include "../../include/mgl/graphics/font.h" #include "../../include/mgl/system/utf8.h" +#include "../../include/mgl/window/window.h" #include "../../include/mgl/mgl.h" #include @@ -225,10 +226,14 @@ void mgl_text_draw(mgl_context *context, mgl_text *text) { text_draw_userdata.context = context; text_draw_userdata.prev_codepoint = 0; + mgl_window_set_texture_blend_func(context->current_window); + context->gl.glColor4ub(text->color.r, text->color.g, text->color.b, text->color.a); mgl_texture_use(&text->font->texture); context->gl.glBegin(GL_QUADS); mgl_text_for_each_codepoint(text, text_draw_callback, &text_draw_userdata); context->gl.glEnd(); mgl_texture_use(NULL); + + mgl_window_set_render_blend_func(context->current_window); } -- cgit v1.2.3