I am running a setup where all glfw calls are on a separate thread so my program doesn’t block when the window is being resized. My issue is that the resize callback is only being called once, when I release the mouse. I would like to get continuous window size updates as I resize the window (which is what happens on linux) so I can smoothly resize my viewport. Is there any way to get that behaviour ?
At the moment I think the best approach would be to explicitly check the window size every frame with glfwGetFramebufferSize
.
There is some discussion on Win32 resizing on #1426.
I think we should consider calling the size callbacks when WM_RESIZE
is called and not just WM_SIZE
, however this might break single threaded code which expects the callbacks to only be called once per glfwPollEvents
call since Windows blocks this function during resizing. Having this as an optional property might be a reasonable approach.
After a lot of experimenting, I have arrived at the following solution, which I’ll share here aswell.
To get smooth rendering while resizing on windows, the best solution is to draw during WM_PAINT
(which means ditching glfw or heavily modifying it to support this).
Even by calling glfwGetFramebufferSize
every frame, the resizes will still be out of sync and the drawing will be jittery. I have not found any other way to deal with this.
If you want to get a callback for WM_PAINT
on Windows in GLFW then use the Window damage and refresh callback.
While messing with polling events in another thread I did end up implementing the platform layer from scratch only to end up finding out there’s no way to get smooth drawing during resize unless you draw during wm_paint. But I forgot to actually check if glfw has a way to draw during wm_paint. Thanks for pointing that out!