From 95f370a720f5c719b5b6d82ae5b0cb9b784b9c8d Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 14 Sep 2020 16:31:54 +0100 Subject: [PATCH] Integer-only ratio logic --- src/Backends/Rendering/SDLTexture.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Backends/Rendering/SDLTexture.cpp b/src/Backends/Rendering/SDLTexture.cpp index 84e88ca8..90eb2ac1 100644 --- a/src/Backends/Rendering/SDLTexture.cpp +++ b/src/Backends/Rendering/SDLTexture.cpp @@ -467,18 +467,15 @@ void RenderBackend_HandleWindowResize(size_t width, size_t height) } // Create rect that forces 4:3 no matter what size the window is - float window_ratio = (float)width / height; - float framebuffer_ratio = (float)upscaled_framebuffer.width / upscaled_framebuffer.height; - - if (window_ratio >= framebuffer_ratio) + if (width * upscaled_framebuffer.height >= upscaled_framebuffer.width * height) // Fancy way to do `if (width / height >= upscaled_framebuffer.width / upscaled_framebuffer.height)` without floats { - window_rect.w = height * framebuffer_ratio; + window_rect.w = (height * upscaled_framebuffer.width) / upscaled_framebuffer.height; window_rect.h = height; } else { window_rect.w = width; - window_rect.h = width / framebuffer_ratio; + window_rect.h = (width * upscaled_framebuffer.height) / upscaled_framebuffer.width; } window_rect.x = (width - window_rect.w) / 2;