shithub: choc

Download patch

ref: 09d1b09dc9eaa35cba27a2272e67949e49a9e969
parent: af271211eb9c173d5247a0ad4b25971f1b4d350f
author: Simon Howard <[email protected]>
date: Tue May 31 18:44:35 EDT 2016

video: Fix aspect ratio when resizing windows.

When resizing windows there is no restriction on the aspect ratio (or
any way to apply such a restriction through the SDL2 API). When windows
are resized, fix the aspect ratio of the window so that we never get
black borders around the game content.

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -322,6 +322,11 @@
             if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0)
             {
                 SDL_GetWindowSize(screen, &screen_width, &screen_height);
+
+                // Adjust the window by resizing again so that the window
+                // is the right aspect ratio.
+                AdjustWindowSize();
+                SDL_SetWindowSize(screen, screen_width, screen_height);
             }
             break;