From 11bf8046d8af1e6c6cc59e681773179b9d62361d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 13 Jan 2021 19:42:06 +0100 Subject: [PATCH] Added screen resolution modifiers to get proper high resolution scaling. --- es-core/src/renderers/Renderer.cpp | 8 ++++++++ es-core/src/renderers/Renderer.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index 76d280fce..d68b1f4b9 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -31,6 +31,9 @@ namespace Renderer static int screenOffsetY = 0; static int screenRotate = 0; static bool initialCursorState = 1; + // Screen resolution modifiers relative to the 1920x1080 reference. + static float screenHeightModifier; + static float screenWidthModifier; static void setIcon() { @@ -97,6 +100,9 @@ namespace Renderer screenRotate = Settings::getInstance()->getInt("ScreenRotate") ? Settings::getInstance()->getInt("ScreenRotate") : 0; + screenHeightModifier = static_cast(screenHeight) / 1080.0f; + screenWidthModifier = static_cast(screenWidth) / 1920.0f; + // Prevent ES window from minimizing when switching windows (when launching // games or when manually switching windows using task switcher). SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); @@ -427,5 +433,7 @@ namespace Renderer int getScreenOffsetX() { return screenOffsetX; } int getScreenOffsetY() { return screenOffsetY; } int getScreenRotate() { return screenRotate; } + float getScreenWidthModifier() { return screenWidthModifier; } + float getScreenHeightModifier() { return screenHeightModifier; } } // Renderer:: diff --git a/es-core/src/renderers/Renderer.h b/es-core/src/renderers/Renderer.h index dae740ae4..10bb80802 100644 --- a/es-core/src/renderers/Renderer.h +++ b/es-core/src/renderers/Renderer.h @@ -156,6 +156,8 @@ namespace Renderer int getScreenOffsetX(); int getScreenOffsetY(); int getScreenRotate(); + float getScreenWidthModifier(); + float getScreenHeightModifier(); unsigned int convertRGBAToABGR(unsigned int color); unsigned int convertABGRToRGBA(unsigned int color);