fix for dpi scale value on linux

This commit is contained in:
Noel Berry 2022-03-16 23:05:38 -07:00
parent 9096ed79a7
commit 5a6a53f4bc

View File

@ -545,21 +545,25 @@ float SDL2_Platform::get_content_scale()
return 2.0f; return 2.0f;
#endif #endif
#if _WIN32 // TODO:
float hidpiRes = 96; // is there a way to get this value properly? My Windows & Linux PC's both seem to thing 96 is correct
#else const float hidpi_res = 96;
float hidpiRes = 72;
#endif
int index = SDL_GetWindowDisplayIndex(window); int index = SDL_GetWindowDisplayIndex(window);
if (index < 0) if (index < 0)
{
Log::error(SDL_GetError()); Log::error(SDL_GetError());
return 1.0f;
}
float ddpi, x, y; float ddpi, x, y;
if (SDL_GetDisplayDPI(index, &ddpi, &x, &y) != 0) if (SDL_GetDisplayDPI(index, &ddpi, &x, &y) != 0)
{
Log::error(SDL_GetError()); Log::error(SDL_GetError());
return 1.0f;
}
return (ddpi / hidpiRes); return (ddpi / hidpi_res);
} }
const char* SDL2_Platform::app_path() const char* SDL2_Platform::app_path()