Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
3  
It's not clear what you mean: In-game GUI? Or GUI for tools? Each one is a very different requirement.. –  jacmoe Aug 3 '10 at 11:48
1  
Who needs tools when you have an ENGINE (epic music) –  Ricket Aug 3 '10 at 13:48
add comment

closed as not constructive by Byte56, Sean Middleditch, Tetrad Jun 16 '13 at 13:50

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

9 Answers

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

share|improve this answer
add comment

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.

share|improve this answer
1  
I believe win32/COM is emulated on Vista and Win 7. Not recommended for High performance... –  Stephen Furlani Nov 8 '10 at 20:17
    
I guess it depends how much of the GUI you'll use in the game. If it's just for the menu system then who really cares, if you're using it extensively in the frame rate crucial section then it needs some work and thought. –  Daemin Nov 10 '10 at 0:32
    
@StephenFurlani Win32 / COM is not emulated on Vista and Windows 7, it is native and full speed. Furthermore ATL/WTL doesn't rely on COM, but DirectX does. –  Daemin Apr 2 '12 at 23:05
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
    
This is what I'm currently using. I find that it has too much dependency though. And I had trouble linking it to my project (IIRC, the license said that I can only link to the library) –  MrValdez Jul 22 '10 at 7:48
6  
It has a ridiculous amount of dependencies. It bloated my tiny demo game to 50 MB! –  knight666 Jul 22 '10 at 8:04
    
What? I think you're doing it wrong :) The weight of the CEGUI DLLs in my game is less than 3 MBs. And to MrValdez: CEGUI is under the BSD license.. –  jacmoe Aug 3 '10 at 11:48
    
MIT license - sorry. CEGUI is under the MIT license. :) –  jacmoe Aug 3 '10 at 14:49
add comment

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.

share|improve this answer
    
Looks interesting. I'm gonna check it out as soon as I can. –  MrValdez Jul 24 '10 at 10:14
add comment

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/

share|improve this answer
4  
IM GUI is an interesting concept, but I've found that there are some problems that pop up when you try to do gamey things. If you want the menu elements to animate in/out you either have to do something like modify the individual position of all the widgets, or do something like modify the GUI transform matrix for that call. It would be easier if you had, for example, a Window container whose actions are translated down to its children and such. Also, for some reason, most IMGUI implementations lack "disabled" widget states. –  Tetrad Jul 22 '10 at 7:15
    
@Tetrad: It's very easy to implement widget groups with auto-layouts, relative positions or absolute positions (Nvidia widgets does this.) It lets you very easily contain widgets inside windows or panels. For the "disabled" state, I can't see why this would not be trivially implemented. For "gamey things", I think the immediate mode concepts are actually more suitable than retained mode, since the widgets are updated every frame. –  Oskar N. Sep 29 '10 at 8:29
add comment

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)

share|improve this answer
4  
WebKit and its kin are more geared toward a refresh rate of once or twice a second, might be tricky to do a HUD for an action-oriented game that way. Would be great for menus or slower bits though. –  coderanger Jul 22 '10 at 6:50
1  
@coderanger: You can write entire games in JavaScript/HTML5. I've published a commercial action game for the Chrome Web Store that runs at 60 FPS just fine in WebKit/Chrome. –  Sean Middleditch Oct 19 '11 at 22:58
add comment

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 :-/

share|improve this answer
    
<pedantic>wxWidgets is also cross-platform</pedantic> though I take your point about engine integration –  zebrabox Aug 3 '10 at 21:58
2  
I said "most popular", not "only" :-P wx has even less support for working with 3D contexts last I looked. –  coderanger Aug 3 '10 at 22:27
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.