| Summary: | SDL 2 Any Desktop Resolution query returns wrong areas | ||
|---|---|---|---|
| Product: | SDL | Reporter: | hubert.vansteenhuyse |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | ewasylishen, sezeroz |
| Version: | 2.0.7 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 10 | ||
|
Description
hubert.vansteenhuyse
2018-02-01 05:12:02 UTC
I think my windows highdpi patch would fix this; I need to fix some merge conflicts and update it (it hasn't been updated since last October). https://github.com/ericwa/SDL-mirror/blob/windows-highdpi Here is a workaround to force DPI awareness: https://discourse.libsdl.org/t/sdl-getdesktopdisplaymode-resolution-reported-in-windows-10-when-using-app-scaling/22389/4 One key point: on Windows, if a process is non-DPI-aware and there is a scale factor >100%, you can't enter the fullscreen mode that is the "native" desktop resolution in pixels (either with SDL_WINDOW_FULLSCREEN or SDL_WINDOW_FULLSCREEN_DESKTOP). e.g. suppose a 2880x1800 pixel monitor using 200% scaling (giving a virtual size of 1440x900). If an app is not DPI aware, it's impossible to change to 2880x1800 pixel fullscreen mode. You can change to other modes, though (1920x1200 pixels etc.) see my comments at: https://github.com/ericwa/SDL-mirror/blob/windows-highdpi/src/video/windows/SDL_windowsmodes.c#L532 Since accessing the "native" fullscreen mode is IMO a feature that I expect to always work, I think most SDL apps should be DPI aware (?) I use the SDL_win32_main.cpp provided by SDL and compile it in my project. Eric was right, one just has to enable the high DPI awareness (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms633543(v=vs.85).aspx). Alternatively, changing the compatibility settings from Windows 10 on the executable itself without the changes in the source code also works. Right click on the shortcut->Properties->Compatibility->Change high DPI settings->High DPI scaling override Adding the following in function WinMain solved my problem: //enable high DPI awareness HMODULE hUser32 = LoadLibrary("User32.dll"); BOOL WINAPI (CALLBACK* dllSetProcessDPIAware)(void) = 0; if(hUser32){ dllSetProcessDPIAware = GetProcAddress(hUser32, "SetProcessDPIAware"); if(dllSetProcessDPIAware) dllSetProcessDPIAware(); FreeLibrary(hUser32); } ... loading "DDRAW.DLL" SDL code ... |