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.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/graphics/text.c b/src/graphics/text.c
index d330dc0..ea60b6a 100644
--- a/src/graphics/text.c
+++ b/src/graphics/text.c
@@ -4,6 +4,8 @@
#include "../../include/mgl/mgl.h"
#include <stdio.h>
+/* TODO: Cache mgl_font_get_glyph */
+
#define TAB_WIDTH 4
static float max_float(float a, float b) {
@@ -95,7 +97,7 @@ mgl_vec2f mgl_text_get_bounds(const mgl_text *self) {
return self->bounds;
}
-static void mgl_text_draw_glyph(mgl_context *context, mgl_font_glyph *glyph, mgl_vec2f position) {
+static void mgl_text_draw_glyph(mgl_context *context, mgl_font_glyph *glyph, mgl_vec2i position) {
context->gl.glTexCoord2f(glyph->texture_position.x, glyph->texture_position.y);
context->gl.glVertex3f(position.x + glyph->position.x, position.y + glyph->position.y, 0.0f);
@@ -116,11 +118,11 @@ void mgl_text_draw(mgl_context *context, mgl_text *text) {
return;
mgl_font_glyph glyph;
- mgl_vec2f position = text->position;
+ mgl_vec2i position = (mgl_vec2i){ text->position.x, text->position.y };
position.y += text->font->character_size;
context->gl.glColor4ub(text->color.r, text->color.g, text->color.b, text->color.a);
- context->gl.glBindTexture(GL_TEXTURE_2D, text->font->texture.id);
+ mgl_texture_use(&text->font->texture);
context->gl.glBegin(GL_QUADS);
for(size_t i = 0; i < text->text_size;) {
unsigned char *cp = (unsigned char*)&text->text[i];
@@ -147,5 +149,5 @@ void mgl_text_draw(mgl_context *context, mgl_text *text) {
i += clen;
}
context->gl.glEnd();
- context->gl.glBindTexture(GL_TEXTURE_2D, 0);
+ mgl_texture_use(NULL);
}