Skip to content

SD: Render while Resizing

Lukas Dürrenberger edited this page Jun 21, 2024 · 3 revisions

Current Situation

While the title just talks about "resizing" there are actually three (or four) different situations that blocks that application flow inside the event loop.

  1. Window is being resized
  2. Window is being dragged
  3. The window's system menu is opened
  4. (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.

Target Situation

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

Callback

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

Threading

This is the approach that Allegro has been using for quite a while, see here.

Parent-Child Window

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.

Custom Resize Handler

If you handle WM_SYSCOMMAND yourself, you could also provide your own resize handler, as for example provided with LooplessSizeMove.

Clone this wiki locally