| Summary: | SDL_SetWindowSize in fullscreen sets display size only once. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Dorian <dorian.apanel> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED ABANDONED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | dorian.apanel |
| Version: | 2.0.5 | ||
| Hardware: | x86 | ||
| OS: | Windows (All) | ||
The bug is actually that SDL_SetWindowSize() works the first time. You are supposed to use SDL_SetWindowDisplayMode() for fullscreen windows. From the documentation of SDL_SetWindowSize(): You can't change the size of a fullscreen window, it automatically matches the size of the display mode. Thanks for response Sam. 1. Maybe some warning should be logged if user calls this function for fullscreen window, or __debugbreak/sigtrap called in Debug mode. 2. It would be helpful to add your quote "You can't change the size of a fullscreen window, it automatically matches the size of the display mode." to 'Remarks' on wiki page: https://wiki.libsdl.org/SDL_SetWindowSize I will also pass this topic to Valve devs. The wiki and header documentation has been updated, thanks! https://hg.libsdl.org/SDL/rev/7051f0e04ebc Hello, and sorry if you're getting dozens of copies of this message by email. We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc. Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report. So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues. (please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!) Thanks, --ryan. |
After entering fullscreen mode and calling SDL_SetWindowSize when user changes resolution, SDL_SetWindowSize changes display resolution only once. Looking at code execution: First call SDL_SetWindowSize will trigger following functions: SDL_SetWindowSize_REAL(SDL_Window *, int, int) w:1280 h:960 SDL_GetWindowDisplayMode_REAL(SDL_Window *, SDL_DisplayMode *) w:1280 h:960 SDL_GetWindowDisplayMode_REAL(SDL_Window *, SDL_DisplayMode *) w:1280 h:960 WIN_SetDisplayMode(SDL_VideoDevice *, SDL_VideoDisplay *, SDL_DisplayMode *): w:1280 h:960 But second call will not change display mode: SDL_SetWindowSize_REAL(SDL_Window *, int, int) w:1280 h:1024 SDL_GetWindowDisplayMode_REAL(SDL_Window *, SDL_DisplayMode *) w:1280 h:960 SDL_OnWindowResized(SDL_Window *) w:1280 h:960 SDL_GetWindowDisplayMode_REAL(SDL_Window *, SDL_DisplayMode *) w:1280 h:960 <- display mode not changed to 1280x1024! Root cause to this is that window->fullscreen_mode.w and window->fullscreen_mode.h are zero in first call. So following code will be triggered in SDL_GetWindowDisplayMode (called in getWindowsDisplayMode): if (!fullscreen_mode.w) { fullscreen_mode.w = window->windowed.w; } if (!fullscreen_mode.h) { fullscreen_mode.h = window->windowed.h; } But second time it will not change fullscreen_mode.w and fullscreen_mode.h. My proposed solution to this is to clear window->fullscreen_mode in SDL_SetWindowSize in fullscreen case: SDL_SetWindowSize(SDL_Window * window, int w, int h) [...] if (window->flags & SDL_WINDOW_FULLSCREEN) { if (FULLSCREEN_VISIBLE(window) && (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) { + window->fullscreen_mode.w = 0; + window->fullscreen_mode.h = 0; window->last_fullscreen_flags = 0; SDL_UpdateFullscreenMode(window, SDL_TRUE); } } else { [...] This bug was observed in Dota2[Vulkan] and older version of Soma. I know that workaround to this would be to additionally change display mode manually, but a lot of developers trust that if first change works, the second will work too.