header image
 

The quest for C# OpenGL GUI

I need a GUI framework for C# that is renderable in an OpenGL context. It needs to be skinnable and have at least the standard GUI controls implemented. It seems easy, but after extensive searching for a week or two, I found nothing. I’m using SFML graphics library. Some candidates:

  • sfgui: looks promising, but no C# bindings out of the box. Unfinished.
  • cpGUI: too limited, C++ only.
  • CEGUI: C++, seems overly complicated. C# port seems dead.
  • GWEN: stumbled upon it by accident while browsing SFML forums. C++, small but have lots of features, skinnable. Written by Garry Newman. 😉

There might’ve been others, but you can see the trend – no usable C# ports. C++ is tricky when it comes to interop with C#, normal P/Invoke is not able to bind to C++ classes from DLL. I didn’t try to achieve such integration before, but GWEN looks too good not to try (and C++ examples work at least). So I googled about C++/C# interop and basically found two options:

  • Creating C++/CLI managed proxy that will act as a bridge between C# and C++ (MSDN explanation). I’ve never touched C++/CLI and would prefer to not need to.
  • Using SWIG. SWIG is supposed to be able to parse C++ code semantically and create wrappers for various languages. It sounds almost too good to be true… and it is. Documentation for it is massive. It has problems with custom operators and same-named identifiers in different namespaces. After spending most of today trying to get it work, I gave up.

So, what we have left? Nothing? No! We can always rewrite the whole thing in C#! Crazy, you say? Not so much I think. GWEN is really not a big project and it’s written in very clean C++ from what I can tell. Rendering portion is neatly abstracted, it even has a separate SFML renderer. I’d rather not “waste time” on GUI library, but if I manage to do that it will be great for the community. We’ll see…

Edit: get it here: GWEN.Net

~ by omeg on July 29, 2011.

C#, code, GUI

Leave a Reply