diff --git a/src/modules/window/Window.cpp b/src/modules/window/Window.cpp index c2a69df2d..e310c3251 100644 --- a/src/modules/window/Window.cpp +++ b/src/modules/window/Window.cpp @@ -28,8 +28,13 @@ namespace window static bool highDPIAllowed = false; +// TODO: find a cleaner way to do this... +// The window backend (e.g. love.window.sdl) is expected to implement this. +void setHighDPIAllowedImplementation(bool enable); + void setHighDPIAllowed(bool enable) { + setHighDPIAllowedImplementation(enable); highDPIAllowed = enable; } diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 0666216a0..fd66a7d77 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -54,10 +54,27 @@ #define APIENTRY #endif +#ifndef SDL_HINT_WINDOWS_DPI_SCALING +#define SDL_HINT_WINDOWS_DPI_SCALING "SDL_WINDOWS_DPI_SCALING" +#endif + namespace love { namespace window { + +// See src/modules/window/Window.cpp. +void setHighDPIAllowedImplementation(bool enable) +{ +#if defined(LOVE_WINDOWS) + // Windows uses a different API than SDL_WINDOW_ALLOW_HIGHDPI. + // This must be set before the video subsystem is initialized. + SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, enable ? "1" : "0"); +#else + LOVE_UNUSED(enable); +#endif +} + namespace sdl { @@ -73,12 +90,6 @@ Window::Window() , hasSDL203orEarlier(false) , contextAttribs() { - // Windows uses a different API than SDL_WINDOW_ALLOW_HIGHDPI. -#if defined(LOVE_WINDOWS) && defined(SDL_HINT_WINDOWS_DPI_SCALING) - // This must be set before the video subsystem is initialized. - SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, isHighDPIAllowed() ? "1" : "0"); -#endif - if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) throw love::Exception("Could not initialize SDL video subsystem (%s)", SDL_GetError());