Network: better prensentation

This commit is contained in:
2023-09-30 02:39:12 +02:00
parent fc92f629a6
commit a345141a71
12 changed files with 314 additions and 58 deletions

View File

@@ -340,12 +340,19 @@ static gui_glyph_texture gui_glyph_texture_create(f32 font_size, u32 capacity)
LOG(LOG_DEBUG, "Font size %f not in cache. Slot size (%d %d)", font_size, glyphs.glyph_max_size.x, glyphs.glyph_max_size.y);
// Precompile some info data
v2u texture_slots;
texture_slots.x = r_render_state.max_texture_size / glyphs.glyph_max_size.x;
texture_slots.y = (glyphs.capacity + texture_slots.x) / texture_slots.x;
for(u32 i = 0; i < glyphs.capacity; i++)
{
v2u position = {
i % texture_slots.x * glyphs.glyph_max_size.x,
i / texture_slots.x * glyphs.glyph_max_size.y
};
glyphs.info[i] = gui_glyph_info{
.codepoint = 0xFFFFFFFF,
.box = {0,0,0,0},
.position = v2u{glyphs.glyph_max_size.x * i, 0},
.position = position,
.advance = 0,
.next = i + 1, // Last .next will be >= capacity (== capacity to be precise), so we will consider it to be NULL
.previous = ((i == 0) ? glyphs.capacity : (i - 1))
@@ -355,7 +362,7 @@ static gui_glyph_texture gui_glyph_texture_create(f32 font_size, u32 capacity)
}
// Initialize texture
v2s texture_size = v2s{glyphs.glyph_max_size.x * glyphs.capacity, glyphs.glyph_max_size.y};
v2s texture_size = glyphs.glyph_max_size * V2S(texture_slots);
u8 *texture_data = (u8*)p_alloc(sizeof(u8) * texture_size.x * texture_size.y);
memset(texture_data, 0, sizeof(u8) * texture_size.x * texture_size.y);