
Help with Tutorial
Posted Tuesday, 25 August, 2009 - 20:09 by oafak inI am new to OpenTK, OpenGL but experienced with C++ and C#. (I downloaded opentk-0.9.8-2). The first exercise with QuickStart worked perfectly in my VisualStudio 2008. Trying to go step-by-step to create a GLControl in a Windows Form was NOT successful:
1. I did not see any "Garbage" as was expected to when I added the GLContol to the form
2. I did not get a black page on the form when I first ran it as expected. Instead, I got a form with a beige background.
3. Nothing else showed up on the control afterwards. The expected yellow triangle was not shown.
I will be grateful for any assistance I can get on these please. In addition, I would be pleased to know if this can work with WPF controls.


Comments
Re: Help with Tutorial
1. The Form should not show any garbage when you add the GLControl. Instead, it should display the color specified by the BackgroundColor (or BackColor) property.
2 and 3. Make sure the GLControl is actually visible. Use the "Bring To Front" menu option to bring it to the front of the z-stack and make sure its size is larger than 0 and that it fits inside the form Bounds (alternatively, you can set
Dock = DockStyle.Fill;for testing purposes).If it still doesn't work as expected, consider attaching your project here (source only, no need for OpenTK.dll) and someone will take a look. This will also help us improve documentation to avoid similar issues in the future.
Re: Help with Tutorial
Thanks for your patience. I have tried your suggestions and still I have not succeeded. I deliberately allowed the form window to be slightly larger than the GLControl. Requested that they both be painted Skyblue and I am sure that the GLControl (glControl1 in my code) is in front. To confirm this, I deliberately added a Windows button intersecting the Form and the GLControl so that the order is clearly shown. The first code is the Form.cs:
This is followed by the generated code by the designer:
And lastly, the program source:
Re: Help with Tutorial
You are missing a call to
glControl1.SwapBuffers()in yourglControl1_Paintevent handler.Moreover, you are likely hitting issue #1071: Not firing Load event for GLControl.
As a temporary workaround, you can add the following code to your Form1 class: