commit 09d1b09dc9eaa35cba27a2272e67949e49a9e969
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Tue May 31 22:44:35 2016 +0100
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Tue May 31 22:44:35 2016 +0100
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.
---
src/i_video.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/i_video.c b/src/i_video.c
index 350c9800..03336d6d 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -322,6 +322,11 @@ static void HandleWindowEvent(SDL_WindowEvent *event)
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;