ded

Dramatic EDitor
Index Commits Files Refs README LICENSE
commit 84772a242d2b10d0457027bde240dde8871a1cfb
parent c0afe67783e19c35ebc95a624d0243e28efa03c5
Author: rexim <reximkut@gmail.com>
Date:   Sun, 11 Jul 2021 02:50:21 +0700

Move glViewport() call outside of the render functions

Diffstat:
Msrc/main.c | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -82,8 +82,6 @@ void render_editor_into_tgb(SDL_Window *window, Tile_Glyph_Buffer *tgb, Editor *
     {
         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(tgb->resolution_uniform, (float) w, (float) h);
     }
 
@@ -118,13 +116,9 @@ void render_editor_into_tgb(SDL_Window *window, Tile_Glyph_Buffer *tgb, Editor *
 
 void render_editor_into_fgb(SDL_Window *window, Free_Glyph_Buffer *fgb, Editor *editor)
 {
-    (void) editor;
-
     {
         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(fgb->resolution_uniform, (float) w, (float) h);
     }
 
@@ -335,6 +329,13 @@ 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,
                       (float) (-(int)editor.cursor_row) * FONT_CHAR_HEIGHT * FONT_SCALE);