AdrianPi's picture

Tutorial outdated?

Project:The Open Toolkit library
Category:bug report

I've found no need for the loaded member variable and tests in this tutorial:

If things are done as explained in the tutorial, the loaded event for the control is never triggered and the control behaves like a transparent window.

I've simply done like this and it worked like a charm:

public Form1()
        private void Form1_Load(object sender, EventArgs e)
            this.ClientSize = new Size(640, 480);
        private void glControl1_Resize(object sender, EventArgs e)
            int w = glControl1.Width;
            int h = glControl1.Height;
            GL.Viewport(0, 0, w, h); // Use all of the glControl painting area
        private void glControl1_Paint(object sender, PaintEventArgs e)
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Vertex2(0, 0);
            GL.Vertex2(1, 0);
            GL.Vertex2(0, 1);


Comment viewing options

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


I just want to resize the glControl to the size of the containing client area... but I am not getting glControl1_Resize() or the glControl1_Paint() events happening from the code above (nor from the original Chapter 2 tutorial code either). I have hooked in these events to the control via the Form designer. Any ideas for me?

Besides that, the glControl never starts filling the client area either. Any ideas for me?

the Fiddler's picture


Can you please post the contents of the Designer.cs file (or, even better, attach your project so I can reproduce the issue)?

The simplest way to fill the client area is to set the Dock parameter of the glControl to DockStyle.Fill.

karlschiffmann's picture


Thank you for the quick response! Actually, the DockStyle.Fill did not do it for me... what did was I had not had the control "Anchored" on all sides. Now the control fills its container and gets the Resize event. Great.

But I am still not getting the Load event to fire... I just posted the code in the "Not firing Load event for GLControl" thread. (Sorry, I pasted it in before I saw the Upload file button...)

the Fiddler's picture


Thanks, I'll check this and see what the problem is.

AdrianPi's picture


For me, the Dock property set to Fill worked perfectly. It was what I was doing.

the Fiddler's picture


Status:open» confirmed

Load and Resize events should fire correctly starting with SVN rev. 2371 (#1071: Not firing Load event for GLControl.).

The tutorial should be updated to reflect the latest version of the GLControl.