aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics/text.c')
-rw-r--r--src/graphics/text.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/graphics/text.c b/src/graphics/text.c
index 0280edb..3385667 100644
--- a/src/graphics/text.c
+++ b/src/graphics/text.c
@@ -1,7 +1,6 @@
#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 <stdio.h>
@@ -95,12 +94,13 @@ static void mgl_text_for_each_codepoint(const mgl_text *self, codepoint_loop_cal
typedef struct {
mgl_vec2f bounds;
+ mgl_font *font;
} CalculateBoundsUserdata;
static bool calculate_bounds_callback(codepoint_loop_callback_data callback_data, void *userdata) {
CalculateBoundsUserdata *calculate_bounds_userdata = userdata;
calculate_bounds_userdata->bounds.x = max_float(calculate_bounds_userdata->bounds.x, callback_data.glyph_offset.x + callback_data.glyph_width);
- calculate_bounds_userdata->bounds.y = max_float(calculate_bounds_userdata->bounds.y, callback_data.glyph_offset.y + callback_data.glyph->size.y);
+ calculate_bounds_userdata->bounds.y = max_float(calculate_bounds_userdata->bounds.y, callback_data.glyph_offset.y + calculate_bounds_userdata->font->character_size);
return true;
}
@@ -108,6 +108,7 @@ static mgl_vec2f mgl_text_calculate_bounds(mgl_text *self) {
CalculateBoundsUserdata calculate_bounds_userdata;
calculate_bounds_userdata.bounds.x = 0.0f;
calculate_bounds_userdata.bounds.y = self->font->character_size;
+ calculate_bounds_userdata.font = self->font;
mgl_text_for_each_codepoint(self, calculate_bounds_callback, &calculate_bounds_userdata);
return calculate_bounds_userdata.bounds;
}
@@ -248,14 +249,10 @@ void mgl_text_draw(mgl_context *context, mgl_text *text) {
text_draw_userdata.text = text;
text_draw_userdata.context = context;
- 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);
}