Skip to content

Commit

Permalink
rein: smarter GetDPI
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeping committed Oct 23, 2023
1 parent 9c40fb4 commit e2de808
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e2de808

Please sign in to comment.