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?
Added call to Sync which should fix the problem. Will be in version after 0.8