From 8571f24ed6378a1d3fc4dc4f82a87e03b2f88d6b Mon Sep 17 00:00:00 2001 From: radical autist <56npyfygybys@gmail.com> Date: Sun, 11 Jul 2021 14:30:24 +0300 Subject: [PATCH 1/2] close #19 --- src/main.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index 23560b9b..862d9fae 100644 --- a/src/main.c +++ b/src/main.c @@ -398,6 +398,19 @@ int main(int argc, char **argv) } break; + case SDL_WINDOWEVENT: { + switch(event.window.event) { + case SDL_WINDOWEVENT_RESIZED: { + int w, h; + SDL_GetWindowSize(window, &w, &h); + glViewport(0, 0, w, h); + glUniform2f(resolution_uniform, (float) w, (float) h); + } + break; + } + } + break; + case SDL_MOUSEBUTTONDOWN: { const Vec2f mouse_pos = vec2f((float) event.button.x, (float) event.button.y); switch(event.button.button) { @@ -430,14 +443,6 @@ int main(int argc, char **argv) camera_pos = vec2f_add(camera_pos, vec2f_mul(camera_vel, vec2fs(DELTA_TIME))); } - { - int w, h; - SDL_GetWindowSize(window, &w, &h); - // TODO(#19): update the viewport and the resolution only on actual window change - glViewport(0, 0, w, h); - glUniform2f(resolution_uniform, (float) w, (float) h); - } - glyph_buffer_clear(); { for (size_t row = 0; row < editor.size; ++row) { From 2c2c9fa147e3e6b51aefe82775c148c7cd48a2b6 Mon Sep 17 00:00:00 2001 From: Radicalautistt <41646958+Radicalautistt@users.noreply.github.com> Date: Sun, 11 Jul 2021 16:37:22 +0300 Subject: [PATCH 2/2] Update main.c --- src/main.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main.c b/src/main.c index 7c6d274c..3340b92e 100644 --- a/src/main.c +++ b/src/main.c @@ -348,13 +348,6 @@ int main(int argc, char **argv) } } - { - int w, h; - SDL_GetWindowSize(window, &w, &h); - // TODO(#19): update the viewport and the resolution only on actual window change - glViewport(0, 0, w, h); - } - { const Vec2f cursor_pos = vec2f((float) editor.cursor_col * FONT_CHAR_WIDTH * FONT_SCALE,