foxygit / doom Log in
commit 2cc60a0d434c7c7df19cf9d65ec9ed389bc5cb58
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Wed Jun 1 01:07:11 2016 +0100
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Wed Jun 1 01:07:11 2016 +0100

    video: Fix rounding up of window_height adjust.

    The correct behavior here is to round up to the nearest pixel; the past
    logic mostly worked but wasn't quite correct.
---
 src/i_video.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index 7c986023..e0ae5eaa 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -287,9 +287,9 @@ static void AdjustWindowSize(void)

     if (window_width * h <= window_height * SCREENWIDTH)
     {
-        // The +1 here stops us from repeatedly shrinking the screen size
-        // with each call.
-        window_height = (window_width + 1) * h / SCREENWIDTH;
+        // We round up window_height if the ratio is not exact; this leaves
+        // the result stable.
+        window_height = (window_width * h + SCREENWIDTH - 1) / SCREENWIDTH;
     }
     else
     {