Black area during resize

Started by KSergeyP, 25 October 2024, 08:30:33

KSergeyP

When I stretch the window with the mouse, a black area appears and the window is redrawn only when I release the mouse button.
Are there any simple examples with automatic image update when resizing?

texus

I'm assuming you are using the SFML backend and are using Windows? (other backends might have a similar issue though)

This is a known issue in SFML that is related to how resizing works on Windows. See e.g. https://github.com/SFML/SFML/issues/3016

KSergeyP

I'm using SFML Graphics (Windows). Tried SFML Windows - same thing
Which backend is best for Windows?

KSergeyP

Quote from: texus on 25 October 2024, 08:36:34This is a known issue in SFML that is related to how resizing works on Windows. See e.g. https://github.com/SFML/SFML/issues/3016
They write that this is a Windows problem. But QT somehow solves this - by default it works on Windows without these problems.

texus

#4
It is a Windows-issue in the sense that it is a Windows call that hangs during resize. All window libraries will face issues with it, but a library like QT will have workarounds to make things work. In the SFML github issue they also mention some of the things that they can do to make it work in the future.

Other libraries have the same issue, e.g. GLFW's glfwPollEvents also hangs (e.g. https://stackoverflow.com/a/56614042 describes a method to redraw when the mouse is moved during resizing).
SDL recently worked around it by allowing you to bind a SDL_EVENT_WINDOW_EXPOSED callback that would get called during resize (and in which you can then render (see e.g. https://github.com/libsdl-org/SDL/issues/1059).

I have not experimented with any of these workarounds in combination with TGUI though. Although it should be the exact same as rendering otherwise: you call gui.draw() inbetween the locations where you are clearing and displaying the window contents.

As for which backend is the best. For most people either one will work, there are only minor differences. While I love SFML, it is the one that is the least feature-complete and lacks some advanced functionality, while SDL is commonly used in many places so it probably has the most options that can be tuned to get what you want.

KSergeyP

Quote from: texus on 25 October 2024, 09:14:22SDL recently worked around it by allowing you to bind a SDL_EVENT_WINDOW_EXPOSED callback that would get called during resize (and in which you can then render (see e.g. https://github.com/libsdl-org/SDL/issues/1059).

Yes, it works with SDL3
But it stretches with a bit of a slowdown, the black area is visible if you quickly drag it with the mouse, but then it is automatically filled and the layouts are automatically stretched
Perhaps you need to tweak something in the SDL settings for greater smoothness/speed of rendering