Menu

#1 Add Sync call to fix resize rendering problem

closed-fixed
None
5
2010-04-07
2008-08-06
No

Jay L. T. Cornwall to me

I've now made my application do single-threaded OpenGL and it works much better. I found a bug, though, which I can reproduce in the GLTest project.

In GLTest I comment out the TimerElapsed() call to disable animation and comment out the triangle drawing code (just leaving viewport setting and clear). Randomly, when resizing the window - most easily reproduced with the first resize - one of the widgets doesn't redraw to fill the new space but the Render() call definitely occurs and uses the correct new size for the GL.Viewport() call. Minimizing and restoring the window forces a redraw which correctly fills the widget.

I have exactly the same behaviour in my own application, only much more frequently. The expose event handler is definitely called and always renders correctly if I add a small delay to it (Thread.Sleep(50)) before repainting, leading me to suspect a race condition somewhere.

I seem to have fixed this. In the GLWiget ExposeEvent handler I do:

protected void HandleExpose(object sender, ExposeEventArgs e) {
doOpenGLRendering();

e.Event.Window.Display.Sync();
SwapBuffers();
}

With the Sync() call in place the repaint works correctly all the time. I've no idea why it's needed but perhaps this is worth adding to GLWidget's HandleExposeEvent?

Discussion

  • James Talton

    James Talton - 2008-08-29
    • assigned_to: nobody --> jtalton
     
  • James Talton

    James Talton - 2008-10-16

    Added call to Sync which should fix the problem. Will be in version after 0.8

     
  • James Talton

    James Talton - 2008-10-16
    • status: open --> closed
     
  • James Talton

    James Talton - 2010-04-07
    • status: closed --> closed-fixed
     

Log in to post a comment.