diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-19 22:12:52 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-19 22:12:52 +0200 |
commit | 9da3c2188060dc982412d7a6e1cd2051b9ddb6a6 (patch) | |
tree | 18d7cd9ec63c1f2e42dcda3941907f32e34ac241 /src/graphics/font.c | |
parent | 3bdf82eec2c915e91ae487e29d72639f9efcad67 (diff) |
Change from callback to window poll
Diffstat (limited to 'src/graphics/font.c')
-rw-r--r-- | src/graphics/font.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/graphics/font.c b/src/graphics/font.c index 20d9dfa..f55144a 100644 --- a/src/graphics/font.c +++ b/src/graphics/font.c @@ -10,14 +10,14 @@ /* TODO: Test and fix .tcc files */ -int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int font_size) { +int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int character_size) { self->texture.id = 0; self->font_atlas.atlas = NULL; self->font_atlas.width = 0; self->font_atlas.height = 0; - self->size = font_size; + self->character_size = character_size; self->packed_chars = NULL; self->num_packed_chars = 0; @@ -47,8 +47,8 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int f /* TODO: Optimize */ /* Find optimal size for atlas, starting from small to large */ for(int i = 0; i < 4; ++i) { - self->font_atlas.width = (8 + (8 * i)) * self->size; - self->font_atlas.height = (8 + (8 * i)) * self->size; + self->font_atlas.width = (8 + (8 * i)) * self->character_size; + self->font_atlas.height = (8 + (8 * i)) * self->character_size; unsigned char *new_atlas = realloc(self->font_atlas.atlas, self->font_atlas.width * self->font_atlas.height); if(!new_atlas) { fprintf(stderr, "Error: failed to load font %s, error: out of memory\n", filepath); @@ -67,7 +67,7 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int f return -1; } - if(!stbtt_PackFontRange(&pc, filedata.data, 0, self->size, 0, self->num_packed_chars, self->packed_chars)) { + if(!stbtt_PackFontRange(&pc, filedata.data, 0, self->character_size, 0, self->num_packed_chars, self->packed_chars)) { stbtt_PackEnd(&pc); continue; } @@ -84,7 +84,7 @@ int mgl_font_load_from_file(mgl_font *self, const char *filepath, unsigned int f return -1; } - if(mgl_texture_load_from_memory(&self->texture, self->font_atlas.atlas, self->font_atlas.width, self->font_atlas.height, MGL_TEXTURE_ALPHA, NULL) != 0) { + if(mgl_texture_load_from_memory(&self->texture, self->font_atlas.atlas, self->font_atlas.width, self->font_atlas.height, MGL_IMAGE_FORMAT_ALPHA, NULL) != 0) { fprintf(stderr, "Error: failed to load font %s, error: mgl_texture_load_from_memory failed\n", filepath); mgl_filedata_free(&filedata); mgl_font_unload(self); |