dairymilk1980's picture

[solved] MDI + Winforms + GLControl

Hello 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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dairymilk1980's picture

*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.