Good GUI for OpenGL?
I am starting to learn OpenGL with FreeGLUT using the Superbible and the knowledge I have from my elementary graphics to brush up on my skills.
To get more from this experience I want to integrate a GUI to overwrite the one FreeGLUT uses, now my question is this: is this thing possible and what library should I use?
Some characteristics for the library:
- Open source
- Multi-platform (Linux and Windows)
If you have any other recommendations please feel free to post them along with your answers for my problem.
Added bounty - additional requirement: must have cross-platform file io dialogs.
I haven't yet tried it myself, but this looks very interesting:
EDIT: Since you'll need a context to render to, I would recommend either SFML or SDL 1.3.
I use libRocket and it is absolutely wonderful! Pains of HTML are present in the library too, but with some fooling around with it, you get around anything virtually :D
Seems to have stalled (no updates for a couple of years). Also, browsing through the docs doesn't give a really good view of what's it actually like. The docs are generally way too low-level.
You could also try out GLFW to create a render context
Crazy Eddie's GUI (CEGUI) is popular, and you can either crib one of the existing renderer backends or write your own targeting whatever OpenGL-backed API you want. It is open source, multi-platform, and C++. However, it values consistency, which is not always a good UI principle for games, which may have dozens of custom controls used in exactly one place.
A recent popular pattern is immediate mode GUI (IMGUI), which is kind of "no GUI library". It has pluses and minuses - it's very straightforward, but can be tricky to optimize, and I've yet to see really good IMGUI models for advanced controls like combo boxes or tree views. Nor have I see a good implementation of an IMGUI windowing system (and I spend some time trying to write one, which I was never happy with) - it is excellent for simple HUD elements however, and simple to do one-off controls.
I had my first experience of IMGUI recently, and felt that it was a big backwards step. As you say, it's great for a simple HUD or a static toolbar, but pretty awful for anything dynamic, hostile to having artists or designers create layouts, and coerces you towards munging presentation and logic code together in one place.
-1. I get the feeling that CEGUI is popular only because it exists and people mention it as a default goto (like this). When I used it, I found it awkward and extremely clunky.
@bobobobo Agreed. It's popular because it exists. It is the "official" gui for ogre (whatever that means) but I find it quite cumbersome to code. Also, the RAD gui builder is way buggy (still in development).
I recently stumbled across Gwen. It's a GUI library written by the author of Gary's Mod. It's MIT licensed as any good game library should be.
The library has several things going for it.
- Large widget set
Gwen has been under development for a few years and it shows.
- Easy backend renderer customization
This is a big one. The library comes with an OpenGL renderer rebuilt. But making a renderer is simple enough that you'll likely want to build a renderer specific to your game's render system.
- Less filling
Gwen seems to be on the lighter side of game GUI's. No XML, no HTML renderer, just simple C++. Gwen doesn't ship with image loaders either. It expects the renderer backend to handle loading. I like this feature as it keeps the library small and my game's render system already manages textures.
Not the first thing in your milestones but eventually you'll need to customize your GUI to your game.
- C++ skinning
I'm not a web developer and find the html css centric GUIs difficult.
- Input injection
This is big for games. It's always a pain to use GUI systems that want to own the input polling.
The library strives to be cross platform but they admit that you may find problems on less used platforms.
- actively developed
Further, it's much smaller than CEGUI or MyGUI so hacking on it or submitting patches is much more practical.
However, here are the cons for it:
- There's not a single page of documentation. Not even a website anymore, just the github repo.
- The packaged renderers lack portability, so you'll need to write your own in case you need it.
Lacks documentation, not portable (yet), opengl back-end unfinished, etc. Couldn't figure from online materials whether it has file io dialogs (or dialogs at all, for that matter).
I agree the documentation is lacking. The core library is cross-platform. However the renderer and input systems are lacking for other platforms. For me that's not an issue as I built a renderer tailored to me render system.
Not having xaml/html/css is not a plus that's for sure. That's what these things were made for and they do it much better than C++ can.
- Large widget set
Sorry for the late reply, but you may want to take a look at an OpenGL UI framework called GG. GG was developed as part of the FreeOrion project and is included in their SVN repository (and their downloadable SDK). It seems pretty capable. I've included a screenshot below; you can click the image to view the full version.
I just spent an entire evening on it and it really, really needs a CMake file. I like the look and feel, I don't like that it uses Boost.
I've been fiddling with both QuickGUI and MyGUI. They're both Ogre GUI libraries that recent dropped the ogre requirement. I don't have too much experience with either yet, but it looks like I'll be sticking with QuickGUI, as it is much smaller and simpler.
I'm not sure if the QuickGUI wiki has been updated yet to point to the newest Ogre-free version. Here is the latest release.
There repo has seen a few cross-platform updates, so you'll be better off using the svn directly.
Lastly here is the brief wiki on how to add diferent rendering backends. http://www.ogre3d.org/tikiwiki/QuickGUI+Integration+Tutorial
MyGUI seems to have more features at the cost of getting bloated. And honestly if simplicity isn't a requirement CEGUI blows MyGUI out of the water.
I tried MyGUI and it's indeed extremely bloated, don't really recommend it if you want to save up space. Still fiddling to get QuickGUI to work.
I have tried both, used CEGUI for the longest time but it was absolutely horrendous not to mention extremely slow with lots of text. I switched to MyGUI recently, and it has been working out nicely. Their layout and skin editors are very very neat. I am not sure about the bloat, I think CEGUI is vastly bloated in comparison. Some of the practices in MyGUI are weird (for example, += operator for assigning delegates, and casting is done in a weird fashion as well - the authors are actively developing it and listening to suggestions which is great) but overall I prefer it over CEGUI.
I would recommend QT, as it's cross platform, C++ and you can get an Open Source version of it with the LGPL license. It's also easy to use and have a lot of pre-made components you can use.
It doesn't say it should be OpenGL based, or am I misunderstanding the question completely? I read it as he wan't something to take over for freeGLUT, which QT is more than capable of.
I'd second this! I use qt and it has almost everything one needs when they are starting. Over the years it has become very stable, with a good support. They also have a framework for games called gluon.
The problem with QT and frameworks in general is they control the main loop. That is usually does not lend itself well games.
The creators may shoot me for saying so, but I found GLFW to be just awesome at creating cross-platform GUI frameworks. The GLFW development folks go on and on about GLFW does not handle GUI. It does however do a nice, simple, clean and totally portable job of handling graphics, events and mouse/keyboard/joystick tasks.
The nice thing about GLFW for me is that it is fairly small, requires no system specific code, no GLUT and is well maintained. Has been stable for use on OpenGL 4.1 projects so far. Compared to something like SDL I love the tiny overhead and it was easy as pie to write GUI handler classes.
Alternatively, take a look at FLTK. It can be used for all sorts of things and re-purposed very simply. It is used really for application building but is perfectly capable of handling 3D objects and is built on OpenGL. Very small, well supported and while I don't see many people making custom interfaces on the game design level, there are some that seem to work great.
Isn't glfw just a library for abstracying windowing code on desktop platforms? How are you able to create graphics with it?
@GabrieleVierti well as I said it handles cross-platform accelerated input as well. beyond that it more specifically helps you get a barebones OpenGL or Vulkan context and handles a lot of the boilerplate. With the context I just implement a histogram pyramid of the hotspots over the screen and use that as the main part of the click/type event handler. then controls associate to some place on the pyramid. normal drawing commands for setting the actual graphics. any UI kit for web stuff works fine or more domain-specific art
It would be much easier to just add a pre-made gui framework (like dear ImGui)