shithub: cstory

Download patch

ref: 95f370a720f5c719b5b6d82ae5b0cb9b784b9c8d
parent: 746ebb822c3e8231c4d8513c27ba80ee5666dede
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Sep 14 12:31:54 EDT 2020

Integer-only ratio logic

--- a/src/Backends/Rendering/SDLTexture.cpp
+++ b/src/Backends/Rendering/SDLTexture.cpp
@@ -467,18 +467,15 @@
 	}
 
 	// 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;