fix: fixed the screen flickering issue when resizing the window from … #616
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…the bottom.
Describe the issue (if no issue has been made)
A lot of people may have overlooked an issue where there is a flicker or delay in the screen when adjusting the window size from below the window. This is due to the improper handling of GLFW input events timing. We should handle input events at the beginning of the main loop, instead of handling events and swapping buffers at the end of rendering.
PR impact (Make sure to add closing keywords)
List of related issues/PRs this will solve:
Proposed fix (Make sure you've read on how to contribute to Hazel)
Add a new interface method OnRender in Window.h, move the SwapBuffer operation to OnRender, and move the glfwPollEvents operation to OnUpdate. Call the window's OnUpdate at the beginning of the main loop in Application and call OnRender at the end of the render pipeline. Further discussion may be needed for naming, it could also be OnPreUpdate and OnLateUpdate, but for now, OnUpdate and OnRender should be more appropriate according to the current logic.
Additional context
Tested on Windows 10, 19041.264