From e2de808bdacbe04086011b8144059a755d69e374 Mon Sep 17 00:00:00 2001 From: Peter Kosyh Date: Mon, 23 Oct 2023 22:54:19 +0300 Subject: [PATCH] rein: smarter GetDPI --- src/main.c | 6 +++--- src/platform.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 52d1b38..1ec233e 100644 --- a/src/main.c +++ b/src/main.c @@ -162,14 +162,14 @@ main(int argc, const char **argv) lua_pushstring(L, GetLanguage()); lua_setglobal(L, "LANGUAGE"); - lua_pushnumber(L, GetScale()); - lua_setglobal(L, "SCALE"); - if (WindowCreate()) { fprintf(stderr, "Can not create window!\n"); return 1; } + lua_pushnumber(L, GetScale()); + lua_setglobal(L, "SCALE"); + for (i = 0; lua_libs[i].name; i++) luaL_requiref(L, lua_libs[i].name, lua_libs[i].func, 1); diff --git a/src/platform.c b/src/platform.c index bdebd23..e52586e 100644 --- a/src/platform.c +++ b/src/platform.c @@ -206,7 +206,8 @@ GetScale(void) return (float)r; #else float dpi; - if (SDL_GetDisplayDPI(0, NULL, &dpi, NULL)) + int disp = window?SDL_GetWindowDisplayIndex(window):0; + if (SDL_GetDisplayDPI(disp, NULL, &dpi, NULL)) return 1.0f; return dpi / 96.0f; #endif