-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix window resize graphical glitches #1216
Comments
We may have a slight issue with when we handle drawing versus polling for events. From the SDL documentation:
Meanwhile we have this game loop in NAS2D, we we interleave drawing, dispatching events, and swapping the draw buffer: void Game::go(State* state)
{
// ...
// Game Loop
while (stateManager.update()) // Draw and dispatch events
{
Utility<Renderer>::get().update(); // Swap back buffer
}
} bool StateManager::update()
{
if (mActiveState)
{
State* nextState = mActiveState->update(); // Draw to back buffer
// ...
Utility<EventHandler>::get().pump(); // Dispatch events, including resize
// ... void RendererOpenGL::update()
{
SDL_GL_SwapWindow(underlyingWindow);
} So contrary to the SDL recommendation, we do:
This seems like an invitation to cause flickering for resize events. With that said, moving the Saw this thread from a few months ago: Kind of sounds like the resize flicker may have something to do with SDL rather than how we use it. It might also be a Linux SDL issue. There's also a recent issue: |
There are graphical glitches when dragging to resize the window.
This can be illustrated with the
test-graphics
project. HitF2
to enable window resizing, then drag the window borders. Dragging from the bottom produces the most extreme glitches, with lots of bouncing and flickering.I suspect there is a delay between the resize event and when OpenGL render parameters get updated. I believe this leads to some frames being drawn with the old parameters, rather than the updated window dimensions.
Dragging either the bottom or top borders causes the image to bounce and flicker, and can leave an unpainted area along the bottom edge. Dragging from the left or right can leave an unpainted area along the right edge, though without any bounce.
OpenGL has an origin in the bottom left, whereas most UI drawing is done relative to the top left. This perhaps explains some of the asymmetry in the glitches. When dragging the bottom or top borders, there is a mismatch between OpenGL's bottom left draw origin, and the UI's top left origin. During that period of mismatch, things are drawn at a different vertical offset than normal, causing the up and down bouncing, and flickering.
A moving left side produces fewer glitches since drawing is expected to be relative to the left side, though it does leave an area with no painting along the right edge for a brief moment.
The text was updated successfully, but these errors were encountered: