From: bones_was_here Date: Wed, 10 Apr 2024 12:58:26 +0000 (+1000) Subject: vid: [Windows] fix disabling of OS DPI scaling X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5b610bc93388a22c99aebe29b224e1fa5282b937;p=xonotic%2Fdarkplaces.git vid: [Windows] fix disabling of OS DPI scaling d33a1d0ffb434270de498c386271e484f90e6716 didn't actually work cos I hadn't found where the good SDL documentation was, and didn't have a high DPI Windows test machine. Signed-off-by: bones_was_here --- diff --git a/vid_sdl.c b/vid_sdl.c index 11868087..7bd5be3b 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -1532,6 +1532,16 @@ void VID_Init (void) Cvar_RegisterCallback(&vid_mouse_clickthrough, VID_SetHints_c); Cvar_RegisterCallback(&vid_minimize_on_focus_loss, VID_SetHints_c); + // DPI scaling prevents use of the native resolution, causing blurry rendering + // and/or mouse cursor problems and/or incorrect render area, so we need to opt-out. + // Must be set before first SDL_INIT_VIDEO. Documented in SDL_hints.h. +#ifdef WIN32 + // make SDL coordinates == hardware pixels + SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, "0"); + // use best available awareness mode + SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2"); +#endif + if (SDL_Init(SDL_INIT_VIDEO) < 0) Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError()); if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) @@ -1726,12 +1736,6 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) #endif } - // DPI scaling prevents use of the native resolution, causing blurry rendering - // and/or mouse cursor problems, so we need to opt-out. -#ifdef WIN32 - SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "1"); -#endif - VID_SetHints_c(NULL); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);