vtgl

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

Commit: 9e22de408da34435d16f3a204e1d63ad8a900e0c
Parent: a8c5fa537bcb7eecb5a4f2da8a0d8a45ed6202a3
Author: Randy Palamar
Date:   Tue, 22 Oct 2024 13:20:47 -0600

set projection matrix on every frame; delete redundant code

projection matrix can be handled better when I implement a file watcher

Diffstat:
Mfont.c | 1-
Mfrag_render.glsl | 10+++++-----
Mvtgl.c | 5++---
3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/font.c b/font.c @@ -315,7 +315,6 @@ init_fonts(FontAtlas *fa, Arena *a, iv2 glyph_bitmap_dim) i32 w = scale * (x1 - x0) + 0.5; i32 max_tiles_x = glyph_bitmap_dim.x / w; i32 max_tiles_y = glyph_bitmap_dim.y / h; - stbtt_ScaleForPixelHeight(&f->font_info, f->fontsize); GlyphCache *gc = &fa->glyph_cache; gc->cache_len = round_down_power_of_2(max_tiles_x * max_tiles_y); diff --git a/frag_render.glsl b/frag_render.glsl @@ -52,14 +52,14 @@ unpack_glyph_position(uint glyph_position) void main() { - vec2 pixel_coord = fragment_pixel_coordinate; + vec2 pixel_coord = fragment_pixel_coordinate - top_left_margin; - uvec2 cell_index = uvec2((pixel_coord - top_left_margin) / cell_size); - vec2 cell_pos = mod((pixel_coord - top_left_margin), cell_size); + uvec2 cell_index = uvec2(pixel_coord / cell_size); + vec2 cell_pos = mod(pixel_coord, cell_size); vec3 result; - if (pixel_coord.x > top_left_margin.x && cell_index.x < term_size_in_cells.x && - pixel_coord.y > top_left_margin.y && cell_index.y < term_size_in_cells.y) + if (pixel_coord.x > 0 && cell_index.x < term_size_in_cells.x && + pixel_coord.y > 0 && cell_index.y < term_size_in_cells.y) { RenderCell cell = cells[term_size_in_cells.x * cell_index.y + cell_index.x]; diff --git a/vtgl.c b/vtgl.c @@ -137,8 +137,6 @@ update_uniforms(Term *t, enum shader_stages stage) break; case SHADER_LAST: ASSERT(0); break; } - - set_projection_matrix(&t->gl); } static iv2 @@ -538,7 +536,6 @@ fb_callback(GLFWwindow *win, i32 w, i32 h) t->gl.window_size = (v2){.w = w, .h = h}; glViewport(0, 0, w, h); - set_projection_matrix(&t->gl); glActiveTexture(GL_TEXTURE0 + t->gl.fb_tex_unit); glBindTexture(GL_TEXTURE_2D, t->gl.fb_tex); @@ -807,6 +804,8 @@ do_terminal(Term *t, f32 dt) update_selection(t); + set_projection_matrix(&t->gl); + RenderPushBuffer *rpb = alloc(&t->arena_for_frame, RenderPushBuffer, 1); glUseProgram(t->gl.programs[SHADER_RENDER]);