-
Notifications
You must be signed in to change notification settings - Fork 1.7k
SD: Render while Resizing
While the title just talks about "resizing" there are actually three (or four) different situations that blocks that application flow inside the event loop.
- Window is being resized
- Window is being dragged
- The window's system menu is opened
- (Holding down one of the window's buttons)
In all of those cases, the normal main + event loop won't be executed for the duration of these actions.
One of the main concerns from users is, that they get a smearing effect while resizing of black borders until the resize is finished. This complicates things if you try to fit for example a specific UI sizing.
Note
It's important to note, that if the application gets out of sync or disconnects, while resizing the window, it's really considered a logic issue. Blocked CPU time can happen in other cases as well, which should be properly handled in the application logic.
See also the open issue: #3016
There are multiple potential approaches to solve this and none of them are trivial. Some will also not solve the issue for all the shown situations.
- Callback
- Threading
- Parent-Child Window
- Custom Resize Handler
This is the approach that SDL has chosen in late 2023. See the discussion and the commits for SDL 2 and SDL 3.
This has also been the approach for specific implementations in #1601 and #1604.
Example implementation: https://github.com/SFML/SFML/compare/master...JonnyPtn:resize_callback
This is the approach that Allegro has been using for quite a while, see here.
This approach is a bit more involved, as you'll introduce threading and two windows. It was implemented in a way that doesn't require modifying SFML and publish on the SFML Community Wiki.
If you handle WM_SYSCOMMAND
yourself, you could also provide your own resize handler, as for example provided with LooplessSizeMove.