foxygit / doom Log in
commit 073465c31d1cbdd42685c79b35f738bb385592d3
Author:     Mike Swanson <mikeonthecomputer@gmail.com>
AuthorDate: Sun Mar 18 01:08:56 2018 -0700
Commit:     Mike Swanson <mikeonthecomputer@gmail.com>
CommitDate: Sun Mar 18 01:08:56 2018 -0700

    video: Don't enforce an 8:5 ratio when correction is not enabled.

    As outlined in #968, this removes the 8:5 ratio in both fullscreen
    and windowed modes, allowing the game screen to scale to any arbitrary
    resolution or window size, no black borders visible!
---
 src/i_video.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index 77d66240..989d447d 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -290,15 +290,18 @@ void I_StartFrame (void)
 // ratio consistent with the aspect_ratio_correct variable.
 static void AdjustWindowSize(void)
 {
-    if (window_width * actualheight <= window_height * SCREENWIDTH)
-    {
-        // We round up window_height if the ratio is not exact; this leaves
-        // the result stable.
-        window_height = (window_width * actualheight + SCREENWIDTH - 1) / SCREENWIDTH;
-    }
-    else
+    if (aspect_ratio_correct)
     {
-        window_width = window_height * SCREENWIDTH / actualheight;
+        if (window_width * actualheight <= window_height * SCREENWIDTH)
+        {
+            // We round up window_height if the ratio is not exact; this leaves
+            // the result stable.
+            window_height = (window_width * actualheight + SCREENWIDTH - 1) / SCREENWIDTH;
+        }
+        else
+        {
+            window_width = window_height * SCREENWIDTH / actualheight;
+        }
     }
 }

@@ -1240,9 +1243,12 @@ static void SetVideoMode(void)
     // time this also defines the aspect ratio that is preserved while scaling
     // and stretching the texture into the window.

-    SDL_RenderSetLogicalSize(renderer,
-                             SCREENWIDTH,
-                             actualheight);
+    if (aspect_ratio_correct)
+    {
+        SDL_RenderSetLogicalSize(renderer,
+                                 SCREENWIDTH,
+                                 actualheight);
+    }

     // Force integer scales for resolution-independent rendering.