I'm building my own game engine in C++ and I'm currently deciding on what user interface I should use.
Should I use a library? Should I make my own?
I'm building my own game engine in C++ and I'm currently deciding on what user interface I should use.
Should I use a library? Should I make my own?
In fact, Qt widgets can be integrated with OpenGL and OpenGL can be easily integrated with Qt (QGLWidget). Of course, the platform native looking widgets might not be exactly what you are looking for, but do not worry, there are ways to customize them, create your own or use something else which would better suit your needs, such as Qt Quick (which you should be able to integrate as well).
If you are interested, do not miss these links: Widgets enter the third dimension: WolfenQt and Accelerate your widgets with OpenGL
I don't think you should write your own, the task of creating a game engine is so huge by itself, if you around there are many many libraries with good licenses that you could use, and modify to your liking.
For a game engine I would go for an Immediate mode GUI. More informations here: http://www.mollyrocket.com/forums/viewtopic.php?t=134
The key idea is to draw the component and control the interaction at the same time:
if (button(id, position, size))
{
button_was_pressed();
}
For one, Unity uses a similar concept.
You can find an implementation by NVIDIA, used in their demos: http://code.google.com/p/nvidia-widgets/
Personally, I would recommend CEGUI. It's open source and pretty good. However, what you have to keep in mind is that it can be very, very verbose if you write out everything by hand.
But, on the plus side, it has renderers for both OpenGL and DirectX. I managed to put it on top of the template I normally use, which writes to a texture directly using a VBO (it's kind of hacky).
The game in question was for a networking assignment. The assignment was to have a networked game, with a lobby. I knew the lobby was going to be a pain in the neck to make, so I picked a library that did most of it for me.
The problem with most GUI libraries (Qt is probably the most popular C++ one that isn't Windows-only) is that most won't integrate well into an engine. Traditionally in a GUI app, the GUI library controls the main loop and you just hook up callbacks to events. In a game engine you generally want to control the loop, so it can be tricky at best. Maybe you are looking for something that will just handle drawing controls and dialogs and such into an 3D context you pass it? Those can be a lot harder to find :-/
I strongly believe in write your own but then again I'm very oldskool. Fighting with yet another GUI lib to do just that one thing that you want tends to drive me nuts, added to the fact that most game GUIs are quite trivial so you don't have to go all-out on MDI and super OO design where buttons can have scrollviews that highlight when you happen to hover over a taskbar on the side of a checkbox with draggable thumbs - or something like that. Different strokes for different folks I guess.
One option that might be worth investigating is using WebKit to render your user interfaces and doing all your UI with CSS/HTML/Javascript.
Here's an open source implementation (Berkelium), and here's a closed source, commercial implemtation (Awesomium)
I would suggest IUP - Portable User Interface: http://www.tecgraf.puc-rio.br/iup/
I've only used it with the Lua programming language but it was very easy to use. It only comes in C, LED and Lua flavors but you can easily make a wrapper for it.
I am personally using CEGUI in my game project, and it is a pretty robust solution. Problem is, sometimes it almost feels like to make one tiny change your altering tons of files.
I have not used it, but libRocket just went completely free, removing all license fees and what not. The cool part about this lib is that you write it in html/css syntax. http://librocket.com
Just raising an interesting suggestion, if developing the game for Windows, use the Win32 API. Just use the normal windows controls (I would recommend using the ATL/WTL libraries) but make them owner drawn.
I saw this technique being used in the first Unreal Tournament game, while looking through the publically released headers (for mod makers).
One of the key benefits to doing this is having the whole Windows UI infrastructure at your disposal, as well as maintaining the user's preferences for keyboard repeat rate, mouse sensitivity, double click speed, and other things. Also if you obey the rules the interface will be fast and flicker free.
The drawbacks are that you'll still have to write some code to subclass the windows controls to make them owner draw so that you can apply your own graphics and effects to them.
Just throwing this out as an idea.