OpenTK, GTK#, GLControl, and GLWidget


Posted by Cynic | Posted in .NET, C#, Linux, Software, Solutions to Problems, Windows | Posted on 30-06-2012

Sigh… So I’m banging my head against the wall trying to get a GLControl working in a GTK# project in MonoDevelop… Not gonna work.

The GLControl inherits from System.Windows.Forms.UserControl, so you basically end up resorting to exactly what you wanted to avoid in the first place by using GTK#, i.e. Windows Forms. Here’s an image of the error (click to enlarge):

OpenTK GLControl error

Instead, you need to use a GLWidget with GTK#.

Anyways, hopefully that will help someone from having a bloody forehead.

I’d been trying to add a reference to OpenTK.GLControl.dll and trying to get it to work in the visual designer (stetic) with no luck. I searched around for answers, and didn’t get any. I then simply tried to add it manually. And that was it. The error.

People have complained about OpenTK not really having the best documentation, but I’m going to stick with it for a while longer and hope that I can fudge my way through it enough to finally get to that stage where I can be productive. It seems like with things like this, the ramp up time and effort that it takes to get started is the most painful part. From past experience, I’m expecting things to finally smooth out in the very near future.

So, on to OpenTK with GTK# and MonoDevelop!



  • And naturally as I’m poking along, I find this:

    With the answer I just have above… sigh…

  • I am in the same boat, although using VS2010 — got a full-screen app running great using GameWindow, but when I want to integrate it to an existing C# app as a second window I poured over the GLControl tutorials, etc. to no avail. Tried adding it to the Toolbox, but couldn’t add it to my form. Tried new-ing one up, but it never shows. Tried “UserControl with CodeBehind” techniques, etc. I have a bloody forehead. I will try your link with crossed fingers!