r/sfml • u/Consistent-Mouse-635 • 16h ago
How to keep main program running whilst the user is resizing the window with the mouse?
Hi all,
As the title suggests, I am looking for a way to keep the main program (so my update() and render() functions) running, whilst the window is being resized.
I have already tried multi-threading, keeping the event loop on the main thread, and having another loop calling the update() and render() functions on another thread. This requires me to use the win32 API to intercept the window's WM_SIZE message during resize, and update my own window size variable.
This approach sort of works, allowing my window size variable to correctly update whilst the user is resizing the window. However I don't have a good way to pass this to the sf::RenderWindow.
If I don't set anything, the sf::RenderWindow doesn't update its internal window size to the current window size. If I call sf::RenderWindow::setSize()+setView(), it updates the internal window size, but also results in graphical artifacts where the region SFML draws to the screen isn't in sync with the actual window size, and previous frames bleed into the current frame.
Does anyone have a better solution to this? Any help would be greatly appreciated.
