
[solved] MDI + Winforms + GLControl
Posted Friday, 26 November, 2010 - 23:58 by dairymilk1980 inHello there.
I am using opentk to render into each of the child windows. The problem I seem to be having is that the windows don't seem to be refreshing/repainting. Each child form contains a new instance of GLControl and I am setting MakeCurrent everytime the pain function gets called.
BTW I am creating these child forms on the fly so every child form invokes the same paint function.
What I see is that the windows will repaint only when I minimise the whole window or maximise the child forms. BTW this is the same behaviour even with setting the window title.
{ if (!is_loaded) // Play nice return; gl_control.MakeCurrent(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); GL.Translate(0, 0, 0); if (gl_control.Focused) { GL.Color3(Color.Yellow); parent.Text = "Focus"; } else { GL.Color3(Color.Blue); parent.Text = "Out of focus"; } // GL.Rotate(rotation, Vector3.UnitZ); // OpenTK has this nice Vector3 class! GL.Begin(BeginMode.Triangles); GL.Vertex2(50, 100); GL.Vertex2(100, 100); GL.Vertex2(100, 500); GL.End(); gl_control.SwapBuffers(); }


Comments
Re: MDI + Winforms + GLControl
*ahem* solved this myself. I had to invalidate the form everytime it lost focus. I was not invalidating it, merely checking for whether it was focused or not. This ended up with a "stuck" screen on the form that just lost focus.