66
\$\begingroup\$

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)
  • C/C++

If you have any other recommendations please feel free to post them along with your answers for my problem.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ OpenGL uses a GUI by default since when? :L \$\endgroup\$ Commented Sep 6, 2010 at 19:54
  • \$\begingroup\$ Meant to say the library i was using, aka FreeGLUT. \$\endgroup\$
    – Cristina
    Commented Sep 6, 2010 at 20:00
  • \$\begingroup\$ Added bounty - additional requirement: must have cross-platform file io dialogs. \$\endgroup\$ Commented Feb 18, 2011 at 11:03
  • 1
    \$\begingroup\$ on sourceforge, tiny file dialogs has several modal function calls. it's a simple C C++ cross-platform file to add to your project. \$\endgroup\$ Commented Feb 26, 2016 at 20:48

9 Answers 9

33
+50
\$\begingroup\$

I haven't yet tried it myself, but this looks very interesting:

librocket

EDIT: Since you'll need a context to render to, I would recommend either SFML or SDL 1.3.

\$\endgroup\$
5
  • \$\begingroup\$ indeed it does look interesting \$\endgroup\$
    – Will
    Commented Feb 18, 2011 at 15:08
  • 2
    \$\begingroup\$ 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 \$\endgroup\$
    – Grimshaw
    Commented Feb 18, 2011 at 22:18
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Nov 29, 2012 at 11:53
  • \$\begingroup\$ No official package for Fedora or Ubuntu either (as far as I can see). \$\endgroup\$
    – ilent2
    Commented Apr 22, 2014 at 13:21
  • 1
    \$\begingroup\$ You could also try out GLFW to create a render context \$\endgroup\$
    – user100681
    Commented Feb 6, 2018 at 6:38
19
\$\begingroup\$

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.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – Kylotan
    Commented Feb 22, 2011 at 16:57
  • 13
    \$\begingroup\$ -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. \$\endgroup\$
    – bobobobo
    Commented Sep 8, 2011 at 4:19
  • \$\begingroup\$ @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). \$\endgroup\$ Commented Jul 12, 2012 at 21:36
  • 1
    \$\begingroup\$ dear imgui seems to be a good example of how versatile IMGUIs can be. I'm yet to try it but it seems quite promising. \$\endgroup\$
    – legends2k
    Commented Nov 2, 2016 at 9:49
13
\$\begingroup\$

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.
Gwen logo
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.
  • Skinable
    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.
  • cross-platform
    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.
  • ???
\$\endgroup\$
4
  • 2
    \$\begingroup\$ 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). \$\endgroup\$ Commented Feb 24, 2011 at 5:59
  • \$\begingroup\$ 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. \$\endgroup\$
    – deft_code
    Commented Feb 24, 2011 at 20:58
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – user441521
    Commented Apr 1, 2015 at 16:44
  • 1
    \$\begingroup\$ This project was abandoned in 2016. As stated on github site: Abandoned: GWEN - GUI Without Extravagant Nonsense. \$\endgroup\$ Commented May 27, 2020 at 15:42
7
\$\begingroup\$

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.

Screenshot of FreeOrion's GG-based UI

\$\endgroup\$
5
  • \$\begingroup\$ It looks like GG is moved to a separate project gigi on sourceforge. \$\endgroup\$
    – deft_code
    Commented Oct 11, 2010 at 19:46
  • \$\begingroup\$ Wouldn't surprise me. They intentionally kept it decoupled from FreeOrion. \$\endgroup\$ Commented Oct 13, 2010 at 17:45
  • \$\begingroup\$ 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. \$\endgroup\$
    – knight666
    Commented Feb 19, 2011 at 0:33
  • \$\begingroup\$ GG can be found here: gigi.sourceforge.net \$\endgroup\$
    – House
    Commented Apr 2, 2013 at 21:43
  • \$\begingroup\$ Good luck getting that to build under windows. \$\endgroup\$
    – 3Dave
    Commented Mar 22, 2014 at 20:21
5
\$\begingroup\$

MyGUI is a rather good solution for both DirectX and OpenGL.

\$\endgroup\$
4
\$\begingroup\$

Have a look at AntTweakBar, it's being used by Cinder. There is also a new GUI library developed for Cinder in the works: SimpleGUI.

If you want to go HTML+CSS there is Awesomium (used by Wolfire Games in their Overgrowth game) and a free alternative called Berkelium.

\$\endgroup\$
1
  • \$\begingroup\$ AntTweakBar is awesome, but rather limited. It's great for what it's designed for - tweaking values and extremely simple integration - but not useful as a generic UI toolkit. \$\endgroup\$ Commented Feb 20, 2011 at 18:13
3
\$\begingroup\$

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.

http://www.stormsonggames.com/downloads/QuickGUI_10_8.zip

There repo has seen a few cross-platform updates, so you'll be better off using the svn directly.

http://stormsonggames.com/svn/SSE/Gaia2/QuickGUI
http://stormsonggames.com/svn/SSE/Gaia2/QuickGUIOgreDemo
http://stormsonggames.com/svn/SSE/Gaia2/QuickGUIOgrePlatform

Username: Anonymous
Password: QuickGUI

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.

\$\endgroup\$
3
  • \$\begingroup\$ 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. \$\endgroup\$
    – Cristina
    Commented Oct 11, 2010 at 18:41
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Samaursa
    Commented Feb 23, 2011 at 7:11
  • \$\begingroup\$ @Samaursa += operator means you can add more than one delegate. \$\endgroup\$
    – Ocelot
    Commented Aug 19, 2015 at 16:49
3
\$\begingroup\$

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.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Isn't glfw just a library for abstracying windowing code on desktop platforms? How are you able to create graphics with it? \$\endgroup\$
    – user100681
    Commented Feb 6, 2018 at 6:42
  • 1
    \$\begingroup\$ @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 \$\endgroup\$ Commented Feb 13, 2018 at 11:45
  • \$\begingroup\$ It would be much easier to just add a pre-made gui framework (like dear ImGui) \$\endgroup\$
    – user100681
    Commented Feb 13, 2018 at 13:04
  • 1
    \$\begingroup\$ ImGui operates in immediate mode, so you'll lose hardware acceleration. the things I mentioned I had to track anyway for the game rendering so adding some 2D overlays was not a major consideration. i can see how that would be a hassle for some projects though \$\endgroup\$ Commented Feb 19, 2018 at 7:06
2
\$\begingroup\$

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.

\$\endgroup\$
5
  • 6
    \$\begingroup\$ Don't think that is an OpenGL based UI. \$\endgroup\$
    – DeadMG
    Commented Feb 18, 2011 at 15:42
  • \$\begingroup\$ 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. \$\endgroup\$
    – martiert
    Commented Feb 18, 2011 at 15:52
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Feb 18, 2011 at 16:22
  • 9
    \$\begingroup\$ The problem with QT and frameworks in general is they control the main loop. That is usually does not lend itself well games. \$\endgroup\$
    – deft_code
    Commented Feb 18, 2011 at 19:07
  • 1
    \$\begingroup\$ If the UI isn't OpenGL, then I recommend getting rid of the main loop, using event based UI and events and timers for the game + graphics. Anyway, I've used QT and I do not recommend it. \$\endgroup\$ Commented Feb 23, 2011 at 19:24

Not the answer you're looking for? Browse other questions tagged .