Recalculate Font on window resize

This commit is contained in:
SamratGhale
2026-03-27 20:40:35 +05:45
parent 00ae6cbc4e
commit f49651384c
7 changed files with 188 additions and 148 deletions
+15 -3
View File
@@ -52,8 +52,20 @@ GlyphState :: struct {
width, height : i32,
}
glyph_delete :: proc(glyph : ^GlyphState)
{
//Delete the textures
glyph_init :: proc(glyph: ^GlyphState, font_path : string = "") {
gl.DeleteProgram(glyph.program_id)
gl.DeleteBuffers(1, &glyph.rect_instances_vbo)
gl.DeleteVertexArrays(1, &glyph.vao)
gl.DeleteTextures(1, &glyph.atlas_texture)
}
glyph_init :: proc(glyph: ^GlyphState, font_path : string = "")
{
ok : bool
glyph.program_id, ok = gl.load_shaders_source(#load("./shaders/font_vert.glsl"), #load("./shaders/font_frag.glsl"), )
@@ -102,7 +114,7 @@ glyph_init :: proc(glyph: ^GlyphState, font_path : string = "") {
}
glyph_draw_font :: proc(glyph_state: ^GlyphState, text: string, pos : [2]f32, color : [4]u8) {
glyph_draw_font :: proc(glyph_state: ^GlyphState, text: string, pos : [2]f32, color : [4]u8, flush : bool = false) {
//using app
//text := get_string(&gap_buf)
@@ -162,7 +174,7 @@ glyph_draw_font :: proc(glyph_state: ^GlyphState, text: string, pos : [2]f32, co
assert(codepoint < 127)
glyph_atlas := glyph_state.atlas_items[codepoint]
if !glyph_atlas.filled
if !glyph_atlas.filled || flush
{
glyph_index := stbtt.FindGlyphIndex(&glyph_state.font_info, c)