Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call EventHandler::pump() first in game loop #1244

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

DanRStevens
Copy link
Collaborator

@DanRStevens DanRStevens commented Feb 26, 2025

Moving EventHandler::pump() first allows resize messages to be processed first, before drawing is done.

Previously, message dispatch was being handled between drawing to the back buffer, and swapping the back buffer. That meant there was a frame of lag where the back buffer being swapped in didn't match the window size after a resize event.

Note: There is still horrible flicker when resizing a window vertically, so this doesn't solve that. It's not even better in any clear way. Though in terms of looking at window sizes between the draw calls and the window sizes for back buffer swap, this does eliminate the frame of lag.


According to the SDL documentation:
https://wiki.libsdl.org/SDL2/SDL_PollEvent

The common practice is to fully process the event queue once every frame, usually as a first step before updating the game's state

In particular, we probably don't want to put event polling between drawing and swapping of the back buffer, like we had it previously. That may be particularly bad when handling a resize event.

Related:

According to the SDL documentation:
https://wiki.libsdl.org/SDL2/SDL_PollEvent
> The common practice is to fully process the event queue once every frame, usually as a first step before updating the game's state

In particular, we probably don't want to put event polling between drawing and swapping of the back buffer, like we had it previously. That may be particularly bad when handling a resize event.
@DanRStevens DanRStevens merged commit 5ca9373 into main Feb 26, 2025
7 checks passed
@DanRStevens DanRStevens deleted the callEventHandlerPumpFirst branch February 26, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant