vtgl

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

Commit: 9f1013ae9084c9abe499a2b58e108731b196cea5
Parent: ff73f9bc324170725e679b93f9d20c0599dba62c
Author: Randy Palamar
Date:   Sun,  7 Jul 2024 09:37:49 -0600

reset pmat when shaders are reloaded

Diffstat:
Mvtgl.c | 35+++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/vtgl.c b/vtgl.c @@ -33,6 +33,26 @@ clear_colour(void) } static void +set_projection_matrix(GLCtx *gl) +{ + f32 w = gl->window_size.w; + f32 h = gl->window_size.h; + + f32 pmat[4 * 4] = { + 2.0/w, 0.0, 0.0, -1.0, + 0.0, 2.0/h, 0.0, -1.0, + 0.0, 0.0, -1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + }; + + glUseProgram(gl->programs[SHADER_RENDER]); + glUniformMatrix4fv(gl->render.Pmat, 1, GL_TRUE, pmat); + glUseProgram(gl->programs[SHADER_POST]); + glUniformMatrix4fv(gl->post.Pmat, 1, GL_TRUE, pmat); +} + + +static void resize(Term *t) { v2 ws = t->gl.window_size; @@ -79,7 +99,7 @@ update_uniforms(Term *t, enum shader_stages stage) case SHADER_POST: for (u32 i = 0; i < ARRAY_COUNT(t->gl.post.uniforms); i++) { t->gl.post.uniforms[i] = glGetUniformLocation(t->gl.programs[stage], - post_uniform_names[i]); + post_uniform_names[i]); //fprintf(stderr, "uniform (POST): %s; id %d\n", // post_uniform_names[i], t->gl.post.uniforms[i]); } @@ -88,6 +108,7 @@ update_uniforms(Term *t, enum shader_stages stage) case SHADER_LAST: ASSERT(0); break; } + set_projection_matrix(&t->gl); update_font_textures(t); } @@ -265,17 +286,7 @@ fb_callback(GLFWwindow *win, i32 w, i32 h) glBindTexture(GL_TEXTURE_2D, t->gl.fb_tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - f32 pmat[4 * 4] = { - 2.0/w, 0.0, 0.0, -1.0, - 0.0, 2.0/h, 0.0, -1.0, - 0.0, 0.0, -1.0, 0.0, - 0.0, 0.0, 0.0, 1.0, - }; - - glUseProgram(t->gl.programs[SHADER_RENDER]); - glUniformMatrix4fv(t->gl.render.Pmat, 1, GL_TRUE, pmat); - glUseProgram(t->gl.programs[SHADER_POST]); - glUniformMatrix4fv(t->gl.post.Pmat, 1, GL_TRUE, pmat); + set_projection_matrix(&t->gl); resize(t); }