Added screen resolution modifiers to get proper high resolution scaling.

This commit is contained in:
Leon Styhre 2021-01-13 19:42:06 +01:00
parent 88b9a76062
commit 11bf8046d8
2 changed files with 10 additions and 0 deletions

View file

@ -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<float>(screenHeight) / 1080.0f;
screenWidthModifier = static_cast<float>(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::

View file

@ -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);