]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
vid: [Windows] fix disabling of OS DPI scaling
authorbones_was_here <bones_was_here@xonotic.au>
Wed, 10 Apr 2024 12:58:26 +0000 (22:58 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 11 Apr 2024 12:12:23 +0000 (22:12 +1000)
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 <bones_was_here@xonotic.au>
vid_sdl.c

index 11868087460cb021753c97bc82a5f442ee2fc742..7bd5be3bb19ca2b3b065d9f30b00d4d61cb205c1 100644 (file)
--- 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);