From 5a6a53f4bc1ef726cb5a7f0724fb0db12b7b3dee Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Wed, 16 Mar 2022 23:05:38 -0700 Subject: [PATCH] fix for dpi scale value on linux --- src/internal/platform_sdl2.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/internal/platform_sdl2.cpp b/src/internal/platform_sdl2.cpp index 5a8a754..1c9560d 100644 --- a/src/internal/platform_sdl2.cpp +++ b/src/internal/platform_sdl2.cpp @@ -545,21 +545,25 @@ float SDL2_Platform::get_content_scale() return 2.0f; #endif -#if _WIN32 - float hidpiRes = 96; -#else - float hidpiRes = 72; -#endif + // TODO: + // is there a way to get this value properly? My Windows & Linux PC's both seem to thing 96 is correct + const float hidpi_res = 96; int index = SDL_GetWindowDisplayIndex(window); if (index < 0) + { Log::error(SDL_GetError()); + return 1.0f; + } float ddpi, x, y; if (SDL_GetDisplayDPI(index, &ddpi, &x, &y) != 0) + { Log::error(SDL_GetError()); + return 1.0f; + } - return (ddpi / hidpiRes); + return (ddpi / hidpi_res); } const char* SDL2_Platform::app_path()