aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-18 12:17:14 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 12:17:14 +0100
commitf4833afa1afa56def5a6d54fa8ce22d3a9b4eb55 (patch)
tree04028456c206ec3ad999320dee2a2dbf3c4ab3e4 /include
parentff6d302d7b0ef4c32dca6e2d0ce12927d517875a (diff)
Move glyph creation for text to render function instead of in set string, clear font glyph background before rendering the text
Diffstat (limited to 'include')
-rw-r--r--include/mgl/graphics/font.h3
-rw-r--r--include/mgl/graphics/text.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/include/mgl/graphics/font.h b/include/mgl/graphics/font.h
index 4bd0428..118a867 100644
--- a/include/mgl/graphics/font.h
+++ b/include/mgl/graphics/font.h
@@ -25,7 +25,8 @@ typedef struct {
} mgl_font_atlas;
struct mgl_font {
- mgl_texture texture; /* Font texture coordinates are in pixel space */
+ /* Font texture coordinates are in pixel space. Note: the texture id may change */
+ mgl_texture texture;
mgl_font_atlas font_atlas;
unsigned int character_size;
mgl_font_char_map char_map;
diff --git a/include/mgl/graphics/text.h b/include/mgl/graphics/text.h
index 08a6c37..89ae541 100644
--- a/include/mgl/graphics/text.h
+++ b/include/mgl/graphics/text.h
@@ -22,6 +22,7 @@ typedef struct {
mgl_color color;
mgl_vec2f position;
mgl_vec2f bounds;
+ bool bounds_dirty;
} mgl_text;
/*
@@ -40,7 +41,7 @@ void mgl_text_set_string(mgl_text *self, const char *str, size_t str_size);
void mgl_text_set_font(mgl_text *self, mgl_font *font);
void mgl_text_set_position(mgl_text *self, mgl_vec2f position);
void mgl_text_set_color(mgl_text *self, mgl_color color);
-mgl_vec2f mgl_text_get_bounds(const mgl_text *self);
+mgl_vec2f mgl_text_get_bounds(mgl_text *self);
/* Returns the position of the character on the screen (relative to the current mgl_view) */
mgl_vec2f mgl_text_find_character_pos(mgl_text *self, size_t index);
void mgl_text_draw(mgl_context *context, mgl_text *text);