Recalculate Font on window resize
This commit is contained in:
+15
-3
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user