Most GUI libraries are terrible

Published June 28, 2013
Advertisement
The title is hyperbole. [size=1]Mostly.

I need a GUI library. RPGs require a robust user interface. I've attempted to write my own GUI systems in the past and this has killed many a project. There was always something I didn't anticipate and couldn't work into my existing design. General application frameworks like Qt typically aren't suited for games due to performance needs and the custom graphics games usually demand (and in Qt's case I'm unsure about installing a whole development framework that rivals .NET and the Java SDK just for a GUI).

My own project has specific constraints that limit what libraries I can use.

  • My game is a hobby project that will be freeware. I'm not getting paid for this game so I can hardly justify paying money for any library or toolkit.
  • My game will be open source. Sine I'm not making money off this game, I might as well not hog the source code. I'm eventually going to put my game up on my Bitbucket account. I actually have a completed game there already, developed with Love. For faintly obvious reasons, I'm going to have a bias for open source libraries

    • I have to worry about the specific license of any library I use. I normally use the Apache 2.0 License for my own projects and I lean towards BSD/MIT/zlib(/Apache) style licenses for third party libraries. Lots to keep track of.

  • I'm developing on a Mac and intend to release my game for Mac and Windows; the Windows port mainly a courtesy of my ability to dual boot. Any library I use ought to be compilable on Mac computers, which usually means C/C++.

  • Beyond that, any library I use would hopefully be well established and actively maintained. Something that's not only available on someone's university web page that hasn't been updated since 1999.

    Web searching has left me with a small pool of candidate libraries: CEGUI, SFGUI, Berkelium, GWEN, and libRocket. Each one falls short in at least one aspect for my project. They might not fall short for your project, but I'm still left wanting.

    CEGUI



    Arguably the final word on open source, C++ based, game oriented GUIs. Beyond handling widgets and input logic, CEGUI also does its own rendering (with a choice of built-in renderers) and handles all of its resource loading and management. For a library meant to be used in other multimedia applications, I don't consider this a plus.

    I would prefer to have an interface I could write against so that CEGUI goes through my game's rendering and resource management system instead of working in its own universe. Granted, I'm using SFML, which is based on OpenGL, and CEGUI has an OpenGL renderer available, but using CEGUI will still introduce inconsistency.

    I've written a sprite system with SFML that makes heavy use of batching and texture atlases, with sprites associated with an ID. To draw a sprite I just need an ID and a transform. CEGUI would have to exist independently of of that. I would have to draw my GUI in a separate step, and I'm not sure how I'd put sprites used in my game in a CEGUI widget short of loading the sprite's image separately into CEGUI.

    I've heard rumours that it's possible to write custom renderers for CEGUI, but I haven't seen anything that tells you how. Support for the Mac is also not the best apparently.

    SFGUI



    SFGUI also controls its own rendering like CEGUI. It's meant to work with SFML though, so in my game it might not be such a mismatch.

    SFGUI's default GUI theme is only coloured borders and rectangles though, and I haven't seen any documentation on how to create a custom theme aside from the source code and Doxygen class documents. SFGUI also requires GLEW as an extra dependency and I've been unsuccessful in building SFGUI on my machine anyway. SFGUI is overall a bit too new for my tastes.

    Berkelium



    There's an interesting school of thought in GUI development about using web technologies to create GUIs. The layout and look of your interface is defined in a markup document while your application just handles the logic. WPF for example uses XAML and C# in much the same way web sites use HTML and JavaScript.

    There are pair of WebKit/Chromium frameworks that lets you display web pages in your program. There is the original and commercial Awesomium and its open source offshoot Berkelium. Both of them promise you the ability to create your application's UI with web technologies. If you can create a web page, you can create a UI for a program with Berkelium in it.

    Berkelium and Awesomium don't use HTML and CSS like WPF uses XAML though. They stuff a whole self-contained web browser into your program. By self-contained, I mean you need to use JavaScript to make your UI dynamic. I have not seen a way to control the DOM through Berkelium's C++ API. Considering that my game engine will be wrapped in Squirrel, I'd be forced to use a total of three programming languages for my game.

    What I'd really want is a pure HTML/CSS renderer. Such a library doesn't seem to exist, except for libRocket (coming later) and the commercial Windows-only library HTMLayout.

    GWEN



    GWEN stands for GUI Without Extravagant Nonsense. There's no HTML. No CSS. No JavaScript. No markup or config files. It doesn't handle rendering. It doesn't handle resource loading or resource management. It's just GUI logic. Anything else you have to provide. In other words, it's designed to not cramp your style.

    It also only has a GitHub page to its name. It used to have an actual web page, but that's now gone. And with the original web site gone, the only real documentation GWEN ever had is now also gone. This doesn't inspire confidence about GWEN's status.

    I'm also unsure about GWEN's skinning system. You give it a texture image containing all the graphics GWEN needs for a skin, but I'm unsure how I'm supposed to define size parameters like margins and paddings.

    libRocket



    Due to the shortcomings of the libraries described above, libRocket ended up being the only library I've actually tried.

    Like Berkelium, libRocket uses HTML and CSS to define interfaces. Unlike Berkelium, libRocket doesn't hide the DOM from you, so you don't have to stick JavaScript in the middle (though you can optionally use Python instead). libRocket fully expects you to write a custom renderer for it, and there's actual documentation on how to do this. libRocket still assumes that the images it's being given are files, but since it lets you create a custom renderer I've been able to take control of this so that it uses sprite IDs instead like the rest of my renderer.

    I'm afraid the project is dead though. libRocket's last commit on its GitHub page is only a couple of months old, but the front page of its main site hasn't been updated in two years and the forums are dead.

    There are a few other quirks with libRocket too. It doesn't use actual HTML and CSS, just its own subset (RML and RCSS). I also haven't wrapped my head around handling RML events application-side yet.

    ***



    I wrote this after scouring the Internet, reading thread after thread about suggested GUI libraries for games. With the current selection today, picking a GUI library is not so much about deciding which one is the best as it's about deciding what I'm willing to put up with.
    Previous Entry The start
    7 likes 24 comments

    Comments

    EDI

    I experienced the same pains you've come up against.

    The pain never really subsided until I chose to write for the web and was able to use the DOM/JQuery.

    June 29, 2013 12:02 AM
    Navyman

    Have you thought about using Java to achieve dual platforms?

    I believe that it would be able to handle the game you have described.

    June 29, 2013 12:54 AM
    AaronWizardstar

    Have you thought about using Java to achieve dual platforms?

    I believe that it would be able to handle the game you have described.

    I suppose looking into Java would be worth a shot. Java is the only other language and toolkit that can work across platforms and that I don't have to pay for. Java is also nicer than C++ - though verbose - so wrapping it in a higher level scripting language like Squirrel may be less necessary.

    If I do go the Java route I'd likely use libgdx. In addition to the usual game library features, libgdx promises a built-in GUI package.

    June 29, 2013 02:11 PM
    Navyman

    Netbeans has a interface builder under the form generator.

    June 29, 2013 02:38 PM
    AaronWizardstar

    That would use Swing though, wouldn't it? It doesn't strike me as especially game oriented.

    June 29, 2013 03:53 PM
    TheChubu

    You can't use Swing components inside OpenGL.

    TWL (Themeable Widget Library) do works with OpenGL in Java using LWJGL as the wrapper for OGL calls. Which means that where LWJGL works (Windows, Linux and Mac as far as I know), TWL works too. For Android I you need to implement an OGL ES renderer, TWL site says that you can use libGDX for that.

    You might want to give it a shot, the site has webstart apps to demo some stuff, and a GUI editor to download.

    June 30, 2013 08:04 AM
    swiftcoder

    You're not *supposed* to use Swing components inside OpenGL.

    Much like every other GUI toolkit, however, if you jump through enough hoops you can render Swing into a bitmap and stream it to a texture (i.e. what Awesomium/Berkelium do for web content). I had a Scala demo lying around that did this, but I seem to have misplaced it...

    That said, I don't view writing a GUI from scratch to be all that complex. I've written a number (both on the side and professionally), and as long as you have a handle on measure, layout, input dispatch, and atlased rendering, it's at most a couple of weeks work.

    June 30, 2013 03:47 PM
    Tispe

    I have been rolling my own IMGUI, quite simple and effective.

    July 02, 2013 04:10 PM
    chlerub

    You are very welcome to try my library called SQUID (http://www.ionstar.org/?page_id=4)

    There's a user forum here (http://www.ionstar.org/forum/), which i check daily.
    It's engine-independent - you implement your own renderer. (it comes with renderer examples)

    It has a lot of features and is easily extendable.

    Source code is not publically available, but generally there is no need to have it.

    You can implement anything you desire by just inheriting the baseclass Control.

    There's also a Unity version in the beta phase right now (http://www.ionstar.org/?page_id=8)

    Have fun!

    July 02, 2013 04:17 PM
    AaronWizardstar

    You are very welcome to try my library called SQUID (http://www.ionstar.org/?page_id=4)

    Thanks for the suggestion. Though it's C# only, while I need something that's C/C++ so that I can have versions for both Mac and Windows (I'm not using Unity).

    July 02, 2013 09:16 PM
    AhmedZaman

    Might I suggest using MonoGame, it is a port of XNA and uses .NET on Windows/Windows Phone or Mono on MacOS/Linux/iOS/Android/OUYA/PS Mobile. Covers almost all the platforms you will ever need.

    Mobile platforms need a paid version of MonoTouch if you have a big game and/or you want to sell your game -- I guess won't be a problem for you, since you're not going commercial.

    http://monogame.codeplex.com/

    Here are some GUI libraries that might help, if you chose C#:

    - http://xui.codeplex.com/ - (my recommendation) It's simple, robust and highly optimised. I find this ideal for games because it is so light-weight.

    - http://nuclexframework.codeplex.com/wikipage?title=Nuclex.UserInterface&referringTitle=Home - this one is really advanced. This might just be for you if you have complex GUI in your game. Claims to have 100% test coverage on its code.

    - http://neoforce.codeplex.com/ - another super complex GUI system.

    Only pain I see for you is the porting process, and (very) rarely there will be a feature in MonoGame that has not yet been ported fully, so that will pose an interesting challenge, but you have full access to the source code, feel free to modify it as you develop your game (like I did).

    Have fun!

    July 04, 2013 07:34 PM
    All8Up

    I feel your pain and also ended up going with libRocket for my work. As you say, the forums and the main library seem pretty dead but in general I find there are enough relatively active branches with specific fixes and such that I've had little problem making it do pretty much everything I want. Not to mention the code itself is pretty clean, I've managed to hack up some fixes for x64 and a couple other things without much real effort. I bound Lua, mostly complete, into the framework so the events are able to call any Lua bound C/C++ functions hooked into the Lua state. It makes using the library a snap, just add in "OnClick="GameEngine.DoSomething()" to your RML and away you go.

    The only real issue I have had was porting the renderer's to OsX. The example I found was out of date and used deprecated functionality so the compiled geometry would fail. I also fixed that up a while back so you may be interested in those changes. Everything is up on https://code.google.com/p/a8u-tutorial-sources/ if you want to take a look. I have some cleanup to perform and the current test is pretty stupid but it excercises much of the needed items. Let me know if you have any questions, I've been working on something else rencently but intend to get back to it in the next week or so.

    July 08, 2013 02:04 AM
    Krohm

    GUI in general is trouble for me, but GUI and 3D games... words fail to describe my disappointment! I've been looking at CEGUI for a while, last time I approached it I set up myself to crack it but later figured out I couldn't make it as I had to put the whole project on hold. My main grief about it is that there has been a time in which its documentation did read as "OMG WE HAS LUA EVRYWR!!1!". While the emphasis is gone now I still think all this fuss about GUI and scripting is overhyped as many people really needs much less.

    Except me apparently. In that regard I don't share much positive thinking about IMGUIs either.

    For various reasons, I'm now looking at web services and moving some of my systems to HTML5+JS. Workflow interop will be a problem, but hopefully nothing JSON cannot solve.

    But for in-game I still feel lost; having whole web browsers doing HTML/JS appears exceedingly overkill for any use.

    July 08, 2013 05:44 AM
    MrJoshL

    You commented on my thread regarding mine that I am making myself. I appreciate your insight and suggestions. I am not working on it, per se, but I still get the source files out and play with it over weekends.

    July 09, 2013 02:54 AM
    SuperG
    My impression is UI systems could brake a game. There are commercial retail games that have bad UI design. So UI need to fit the variouse gameplay mechanics a game can offer. So the way of scripting I see as a productive method to find the best fit by UI designer handeling a very modable UI scripted engine. By playtesting and iterate to get better UI as time permits.

    For me porting is no isue. My main target is winPC. Do not have Mac or linux. And don't play on IOS gadgeds. So as a hobbist I choose to be exclusive.

    How ever I am more conserend if those libaries fix you up with limited feature set.
    So if going to make your own you have more freedom to go for any feature you can imagine. But also a lot more work to do.
    July 09, 2013 04:42 AM
    nhold

    Hrm, like you I found that libRocket was the most acceptable GUI I could find.

    Did you have any other issues with it other than the development is pretty dead? What would you prefer out of a GUI or what how do you think a GUI should work?

    Maybe this could be a discussion on the forums...

    July 09, 2013 07:01 AM
    AaronWizardstar

    Did you have any other issues with it other than the development is pretty dead? What would you prefer out of a GUI or what how do you think a GUI should work?

    I think the biggest issue was wrapping my head around how libRocket's HTML-ness works.

    At one point I thought I'd render my game world then render a GUI on top. libRocket would rather I create a custom HTML element (actually, a custom RML element) that would render my game and place that inside an HTML/RML file, like a regular div element.

    Though when I think about it that kind of makes sense anyway, since the "game world" may not necessarily take up the entire screen background. CRPGs of a certain age are remembered for only using one quarter of the whole screen for depicting the game world for instance.

    July 15, 2013 10:19 PM
    Elvis Enmanuel

    Here comes a new challenger :)

    Today has been released an XAML based GUI called NoesisGUI, the website says that it's multiplatform and looks pretty well:

    How it looks:

    https://twitter.com/noesisengine/status/357288229478735872

    Features:

    http://www.noesisengine.com/noesis_gui_features.htm

    Has someone tested it??

    July 17, 2013 08:22 AM
    AvengerDr

    In case anyone is using SharpDX, DirectX11 and Direct2D have a look at my very own library. It's the latest iteration of a project that started way back in the age of MDX. It is designed to be skinnable, it accepts both Windows Forms and Windows 8 input. It uses Direct2D to do the rendering so it doesn't need any artist-drawn art. For the moment it is being released under the GPLv3 license

    On the Github repository you will also find a sample to display the UI shown in the post I linked.

    July 17, 2013 08:00 PM
    AaronWizardstar

    Here comes a new challenger smile.png

    Today has been released an XAML based GUI called NoesisGUI, the website says that it's multiplatform and looks pretty well:

    How it looks:

    https://twitter.com/noesisengine/status/357288229478735872

    Features:

    http://www.noesisengine.com/noesis_gui_features.htm

    Has someone tested it??

    It's commercial, and it doesn't even seem to have a freeware "indie" or "student" license, so it wouldn't really suit my own project.

    Though with the state of GUI libraries now, if you're running a commercial product that you want to make a living off of, something definitely could be said about paying for a GUI library.

    July 18, 2013 11:38 PM
    cdoty

    As long as you're only interested in simple UI (Confirmation dialogs, name entry, etc.), libRocket isn't too bad, but once you start implementing more serious dialogs (listviews, etc.) there is a lot of missing functionality.

    The best UI I've found, assuming you're targeting Windows and don't need in-game UIs, is DuiLib:

    https://code.google.com/p/duilib/

    It's easy to skin.

    It would be ideal for a game editor, as the dialogs are created as separate windows. It also includes an editor which is useful for laying out the controls. Unfortunately the editor doesn't properly save all properties, requiring that you hand edit the XML to customize the control.

    Here's a link that explains parts of DuiLib (It's in Chinese, but the translation is good enough to work from):

    http://www.cnblogs.com/Alberl/tag/duilib%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B/

    February 07, 2014 08:36 PM
    fruxo

    You could look at my project Turbo Badger.
    It's not well known yet as this is the first announcment i do (and i just recently open sourced it).

    It's zlib license and open source, so use it basically as you like, and of course feel free to contribute ;)

    The coding style ("old-school" C++, but with a tad of C++11 if supported by compiler) is chosen to have virtually no dependencies, and make it easy to integrate into any existing game engine, with implementable interfaces for rendering, font systems etc. (defaults implementations are provided too).

    Some features:
    A very powerful skin system that supports multiple DPI buckets, conditions (think CSS selectors), automatically pack texture atlas among other things.
    There's also touch friendly scrolling, layouting, possibility to spec UI in resource files and many other things...

    There's more info on the github page.

    February 15, 2014 07:56 PM
    cdoty

    You could look at my project Turbo Badger.

    I'm looking forward to digging into this project. It looks like it may work well as an in-game UI for some stuff I'm working on.

    Edit: I downloaded the project and was able to compile it.

    Excellent job, The list of controls is extensive and well implemented, the data source stuff looks easy enough to use, and the code looks very clean and easy to extend, if needed.

    August 08, 2014 05:35 AM
    tinyfiledialogs

    tinyfiledialogs on sourceforge has several modal function calls. It's a simple C C++ cross-platform file to add to your project. It has no init and no main loop.

    February 27, 2016 09:24 AM
    You must log in to join the conversation.
    Don't have a GameDev.net account? Sign up!
    Advertisement
    Advertisement