|
|
@ -15,13 +15,15 @@ |
|
|
|
|
|
|
|
|
|
|
|
SDL_Window *window; |
|
|
|
SDL_Window *window; |
|
|
|
|
|
|
|
|
|
|
|
static double get_scale(void) |
|
|
|
static double get_scale(SDL_DisplayMode *dm) |
|
|
|
{ |
|
|
|
{ |
|
|
|
float dpi, s; |
|
|
|
float dpi, s; |
|
|
|
SDL_GetDisplayDPI(0, NULL, &dpi, NULL); |
|
|
|
SDL_GetDisplayDPI(0, NULL, &dpi, NULL); |
|
|
|
|
|
|
|
// TODO: get the current window's screen not the primary
|
|
|
|
|
|
|
|
printf("w: %d, h: %d\n", dm->w, dm->h); |
|
|
|
s = (1.0/dpi)*25.4; // size of a point
|
|
|
|
s = (1.0/dpi)*25.4; // size of a point
|
|
|
|
// as per standard 14 point should be 3mm
|
|
|
|
// as per standard 14 point should be 3mm
|
|
|
|
return floor((FONT_14PT_SIZE_MM/(14*s))*10)/10.0; |
|
|
|
return fmax(1.0, floor((FONT_14PT_SIZE_MM/(14*s))*10)/10.0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void get_exe_filename(char *buf, int sz) |
|
|
|
static void get_exe_filename(char *buf, int sz) |
|
|
@ -70,12 +72,15 @@ int main(int argc, char **argv) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
SDL_DisplayMode dm; |
|
|
|
SDL_DisplayMode dm; |
|
|
|
SDL_GetCurrentDisplayMode(0, &dm); |
|
|
|
SDL_GetDesktopDisplayMode(0, &dm); |
|
|
|
|
|
|
|
|
|
|
|
window = SDL_CreateWindow( |
|
|
|
window = SDL_CreateWindow( |
|
|
|
"", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
|
|
|
"", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
|
|
|
dm.w * 0.8, dm.h * 0.8, |
|
|
|
dm.w * 0.8, dm.h * 0.8, |
|
|
|
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN); |
|
|
|
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_HIDDEN); |
|
|
|
|
|
|
|
int wd = SDL_GetWindowDisplayIndex(window); |
|
|
|
|
|
|
|
printf("%d \n", wd); |
|
|
|
|
|
|
|
SDL_GetDesktopDisplayMode(wd, &dm); |
|
|
|
init_window_icon(); |
|
|
|
init_window_icon(); |
|
|
|
ren_init(window); |
|
|
|
ren_init(window); |
|
|
|
|
|
|
|
|
|
|
@ -97,7 +102,9 @@ int main(int argc, char **argv) |
|
|
|
lua_pushstring(L, SDL_GetPlatform()); |
|
|
|
lua_pushstring(L, SDL_GetPlatform()); |
|
|
|
lua_setglobal(L, "PLATFORM"); |
|
|
|
lua_setglobal(L, "PLATFORM"); |
|
|
|
|
|
|
|
|
|
|
|
lua_pushnumber(L, get_scale()); |
|
|
|
double scale = get_scale(&dm); |
|
|
|
|
|
|
|
printf("%f\n", scale); |
|
|
|
|
|
|
|
lua_pushnumber(L, scale); |
|
|
|
lua_setglobal(L, "SCALE"); |
|
|
|
lua_setglobal(L, "SCALE"); |
|
|
|
|
|
|
|
|
|
|
|
char exename[2048]; |
|
|
|
char exename[2048]; |
|
|
|