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
I've hit a slight roadblock in making a desktop UI, because I need to be able to run code even if a window is in the resize phase (the user's LMB is pressed but they aren't moving their mouse).
During the resize phase, I can only 'do' stuff on the main thread during the events that get fired when the window is actually resized (window/framebuffer size changed callbacks, and the refresh callback), but there's no way to run code while the user just keeps their mouse still but still holding the LMB.
According to the GLFW source code, glfwPostEmptyEvent posts WM_NULL which I assume is ignored but does cause glfwWaitEvents to return (but only when not resizing though). So it would be nice if it could instead post a custom window message, which gets handled by GLFW, and causes an event to be fired on the main thread, even during the resize phase
The text was updated successfully, but these errors were encountered:
AngryCarrot789
changed the title
A callback fired by glfwPostEmptyEvent, even during window resize
An empty event callback (fired by glfwPostEmptyEvent), even during window resize
Dec 8, 2023
The recommended approach to handle this issue is to decouple event processing from rendering with multiple threads. The main thread handles the event loop with blocking glfwWaitEvents, while a secondary thread continuously renders at the target frame rate, or vsync limit.
For example code, see the Vorbis sample. In this case there's even a third thread handling audio, but it demonstrates nicely how you can pace everything at different rates and avoid any blocking.
I was trying to implement an executor service for the main thread, because I'm trying to implement a retained mode GUI, and while I did manage to get it to work while not resizing the window, it obviously won't work during resize since there's no event that gets fired while the user is not moving their mouse but the LMB is pressed.
The only way I can get it to work is by making my entire application have it's own thread and when it wants to change the size of a window I would use the executor service I mentioned, except it would only be able to execute code when not resizing.
I made a pull request on the GLFW git repo, but I don't know if it will go anywhere honestly, mainly because it only works on windows: glfw/glfw#2443
Description
I've hit a slight roadblock in making a desktop UI, because I need to be able to run code even if a window is in the resize phase (the user's LMB is pressed but they aren't moving their mouse).
During the resize phase, I can only 'do' stuff on the main thread during the events that get fired when the window is actually resized (window/framebuffer size changed callbacks, and the refresh callback), but there's no way to run code while the user just keeps their mouse still but still holding the LMB.
According to the GLFW source code,
glfwPostEmptyEvent
posts WM_NULL which I assume is ignored but does causeglfwWaitEvents
to return (but only when not resizing though). So it would be nice if it could instead post a custom window message, which gets handled by GLFW, and causes an event to be fired on the main thread, even during the resize phaseThe text was updated successfully, but these errors were encountered: