You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, while a window is being resized or dragged, it's currently not possible to refresh the window's content and thus you may get odd smearing effects or black rectangles.
The root cause is the way events are processed on Windows, which never gives control back to the main loop. More specifically, DispatchMessageW doesn't return until the resize is finished.
It's important to note, that if you application gets out of sync or disconnects, while resizing the window, it's really considered an issue in your code. Blocked CPU time can happen in other cases as well, which should be properly handled in your application.
SDL has addressed this issue not to long ago in libsdl-org/SDL#1059 for SDL 2 (libsdl-org/SDL@509c70c) and SDL 3 (libsdl-org/SDL@02f3564). The linked issue also shows a few alternative approaches and discusses why some are better than others. Maybe it can serve as an inspiration for a solution within SFML.
Allegro seems to choose the approach of using a separate thread to handle the resize events. I haven't fully understood when this thread is launched and how it gives control back to the main event loop.
This issue is related to #1601, #1604, #1397, and many more discussion on the forum and Discord
Your Environment
OS / distro / window manager: Windows
SFML version: 2.x / 3.x
Steps to reproduce
Display something dynamic on the window
Resize the window
Expected behavior
The dynamic rendering continues rendering and slowly adjusts in size as the window get larger or smaller
Actual behavior
The rendering stops completely, as well as the application update handling.
The text was updated successfully, but these errors were encountered:
So finally had some time the other day to look into this and this kind of clashes a bit with SFML's classic approach of handling the main loop.
Overall, the implementation is rather trivial, but it essentially requires a callback that can be called. Ignoring events for now, getting this done with the Window example could look a bit like this:
constauto draw = [&]() {
// Clear the color and depth buffersglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Apply some transformations to rotate the cubeglMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.f, 0.f, -200.f);
glRotatef(clock.getElapsedTime().asSeconds() * 50, 1.f, 0.f, 0.f);
glRotatef(clock.getElapsedTime().asSeconds() * 30, 0.f, 1.f, 0.f);
glRotatef(clock.getElapsedTime().asSeconds() * 90, 0.f, 0.f, 1.f);
// Draw the cubeglDrawArrays(GL_TRIANGLES, 0, 36);
// Finally, display the rendered frame on screen
window.display();
};
window.setUnblockedDrawing(draw);
// Start the game loopwhile (window.isOpen)
{
// Process events
...
draw();
}
2024-06-07.12-06-43_edit.mp4
However, maybe it might be a better idea to do a different approach and call DispatchMessage() in a second thread? Not sure that's allowed or possible.
Describe your issue here
On Windows, while a window is being resized or dragged, it's currently not possible to refresh the window's content and thus you may get odd smearing effects or black rectangles.
The root cause is the way events are processed on Windows, which never gives control back to the main loop. More specifically,
DispatchMessageW
doesn't return until the resize is finished.It's important to note, that if you application gets out of sync or disconnects, while resizing the window, it's really considered an issue in your code. Blocked CPU time can happen in other cases as well, which should be properly handled in your application.
I currently see four possibilities:
Also check the solution design for a more in-depth discussion: https://github.com/SFML/SFML/wiki/SD:-Render-while-Resizing
SDL has addressed this issue not to long ago in libsdl-org/SDL#1059 for SDL 2 (libsdl-org/SDL@509c70c) and SDL 3 (libsdl-org/SDL@02f3564). The linked issue also shows a few alternative approaches and discusses why some are better than others. Maybe it can serve as an inspiration for a solution within SFML.
Allegro seems to choose the approach of using a separate thread to handle the resize events. I haven't fully understood when this thread is launched and how it gives control back to the main event loop.
This issue is related to #1601, #1604, #1397, and many more discussion on the forum and Discord
Your Environment
Steps to reproduce
Expected behavior
The dynamic rendering continues rendering and slowly adjusts in size as the window get larger or smaller
Actual behavior
The rendering stops completely, as well as the application update handling.
The text was updated successfully, but these errors were encountered: