vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: 5b78f85254bbe6334da9d14d5c01682752cfa111
Parent: 850094d55c9d8e3463b16a6b37e021363bfc95f8
Author: Randy Palamar
Date:   Sun, 25 Aug 2024 00:19:33 -0600

only send updated portion of glyph to GPU

no need to waste time uploading empty space

Diffstat:
Mfont.c | 4++--
Mvtgl.c | 4++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/font.c b/font.c @@ -194,7 +194,7 @@ render_glyph(FontAtlas *fa, Arena a, u32 cp, Glyph *out_glyph, u32 *out_idx) cg->g.delta.x = gs->bitmap_left; cg->g.delta.y = gs->bitmap_top - cg->g.size.h; - u32 *rgba_bitmap = alloc(&a, u32, MAX_FONT_SIZE * MAX_FONT_SIZE); + u32 *rgba_bitmap = alloc(&a, u32, cg->g.size.h * cg->g.size.w); for (u32 i = 0; i < cg->g.size.h; i++) { for (u32 j = 0; j < cg->g.size.w; j++) { /* TODO: handled coloured glyphs */ @@ -203,7 +203,7 @@ render_glyph(FontAtlas *fa, Arena a, u32 cp, Glyph *out_glyph, u32 *out_idx) } else { pixel = gs->bitmap.buffer[i * cg->g.size.w + j] << 24; } - rgba_bitmap[i * MAX_FONT_SIZE + j] = pixel; + rgba_bitmap[i * cg->g.size.w + j] = pixel; } } *out_glyph = cg->g; diff --git a/vtgl.c b/vtgl.c @@ -132,7 +132,7 @@ update_font_textures(Term *t) if (data) { ASSERT(depth_idx); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, depth_idx, - MAX_FONT_SIZE, MAX_FONT_SIZE, 1, GL_RGBA, + g.size.w, g.size.h, 1, GL_RGBA, GL_UNSIGNED_BYTE, data); } } @@ -177,7 +177,7 @@ get_gpu_glyph_index(Term *t, u32 codepoint, Glyph *out_glyph) if (data) { ASSERT(depth_idx); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, depth_idx, - MAX_FONT_SIZE, MAX_FONT_SIZE, 1, GL_RGBA, + out_glyph->size.w, out_glyph->size.h, 1, GL_RGBA, GL_UNSIGNED_BYTE, data); } return depth_idx;