simonescu's picture

GLControl for Gtk#?

Hello everyone,

I'm curious about the possibility of a GLControl being made for Gtk# controls (widgets)? Since there's only support for Windows.Forms, is there any other way get a non-windowed GameWindow or something of that kind?

Thanks for your time, take care


Comment viewing options

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

You can already use gtkglarea-sharp with OpenTK.

There are also plans for integration with GTK# before OpenTK 1.0 comes out, and JTalton has provided code. It's not a high priority at the moment, but if you wish to contribute things will move faster :).

simonescu's picture

I am aware of GtkGLArea-Sharp, though I haven't been able to find a win32 build library for it. My goal is to develop mono + opengl based applications that can be compiled both on Windows and Linux.

Though I'm still fairly new at OpentK, I'll be sure to contribute, when I can. Thanks for the fast reply!

JTalton's picture

There are a couple of unmanaged projects out there for GTK OpenGL widgets.
* GtkGLArea -
* GtkGLExt -

There is a .NET binding for GtkGLArea.
* GtkGLAreaSharp -
I am not sure if GtkGLArea currently works on Windows.

If you can get cross-platform .NET support working with these I'd love to hear about it, and also how hard it is to get setup.

I have written my own GTK OpenGL Widget:
* Crossplatform - Windows/Linux
* .Net Managed Code - pinvokes directly into the system libraries instead of a wrapper around a managed gtk widget.
* Shared GLContext - So textures, display list, etc, can be shared across widgets.
* Single .cs file and class that can be easily included and used. (Or you can use the binary)
If you compile on Windows, the control works on both Linux and Windows. If you compile on Linux, for some reason it does not work.
I plan on moving my development to Linux now that MonoDevelop 1.0 has been released. I'll look into this issue soon.

I am leaving on a trip, but will provide the source code and binary in a few days on my site.

simonescu's picture


GtkGLAreaSharp is supposed to work on Windows. The only problem is that there just isn't a library compiled for Windows anywhere on the internet to be found. And the Linux dlls in a Windows environment don't work either, for sure. I however contacted the maintainer of this project and he said that he had had a built win32 lib somewhere lying around ... i'm waiting for him to get back to me on this. If it's good news, I'll be sure to post it here.

As for GtkGLArea and GtkGLExt, a win32 build is simillary hard to find and I need a C# component anyway.

Your own GLWidget however sounds great. If you can, please leave the source & binary on your site, I'll check it out.

And thanks for the reply.

the Fiddler's picture

The only problem is that there just isn't a library compiled for Windows anywhere on the internet to be found.
Compiler bugs aside, the linux library should run on windows without problem - or am I missing something?

simonescu's picture


I thought so too. But I get a Type exception every time I call the constructor of GLWidget, so I guess it isn't Windows compatible. Or am I missing something?

the Fiddler's picture

Do you have a link to the source code?

JTalton's picture

GTKSharp GLWidget

If you compile on Windows it seems to work great on Windows and Linux.
For some reason it does not seem to work if compiled on Linux. (That was a while back, it may work.)

It is not a wrapper around a c++ version. It performs direct pinvokes to the system libraries.
It does allow for a shared context between controls.

Feel free to copy/modify/use the code any way you want.

JTalton's picture

Gtk.GLWidget for GtkSharp

After several requests and questions from different sources I decided to look into getting the GLWidget code working better on Linux. (Using Ubuntu 8.04)
* Code works beautifully under Linux and Windows.
* Compiled library that acts as a widget library for MonoDevelop.
* Example project and executable on web site.

I would love to hear about any successes or questions.

keitsi's picture


I have successfully tried your GLWidget example.
Thank you, this will make my day a lot easier :)
I will post you a link if my program ever gets finished.

By the way, it looks like GLWidget isn't compatible with the latest OpenTK DLL.
There's no more OpenTK.OpenGL namespace. I fixed changed that to OpenTK.Graphics, but now am getting error:

Unhandled Exception: System.InvalidOperationException: No GraphicsContext available in the calling thread.
at OpenTK.Graphics.GL.LoadAll () [0x00000]
at MainWindow..ctor () [0x0000d] in /home/keitsi/Lorvia/Lorvia/MainWindow.cs:21
at Lorvia.MainClass.Main (System.String[] args) [0x00005] in /home/keitsi/Lorvia/Lorvia/Main.cs:16