diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-24 04:52:30 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-24 04:52:30 +0200 |
commit | 115630b520668304af1ccd3eb0b13c06e17ecccc (patch) | |
tree | e3949bd4fe36ae3b43c11d4e9ecd0bf523a6e910 /src/graphics/text.c | |
parent | 898b8c95f1f904307c02e978b57301cf1cb0560f (diff) |
Add function to load image from memory, initialize window from an existing window, allow creating text without font/string
Diffstat (limited to 'src/graphics/text.c')
-rw-r--r-- | src/graphics/text.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/graphics/text.c b/src/graphics/text.c index e7b31a0..76fd852 100644 --- a/src/graphics/text.c +++ b/src/graphics/text.c @@ -18,6 +18,10 @@ void mgl_text_set_string(mgl_text *self, const char *str) { self->text = str; } +void mgl_text_set_font(mgl_text *self, mgl_font *font) { + self->font = font; +} + void mgl_text_set_position(mgl_text *self, mgl_vec2f position) { self->position = position; } @@ -43,10 +47,11 @@ static void mgl_text_draw_glyph(mgl_context *context, mgl_font_glyph *glyph, mgl /* TODO: Use opengl buffer object instead */ /* TODO: Cache texture bind to not bind texture if its already bound and do not bind texture 0 */ void mgl_text_draw(mgl_context *context, mgl_text *text) { - const char *str = text->text; - if(!str) + if(!text->text || !text->font) return; + const char *str = text->text; + mgl_font_glyph glyph; mgl_vec2f position = text->position; position.y += text->font->character_size; |