7

Like the title says, I'm looking for a library that's platform-agnostic and lightweight, for the purpose of displaying buttons, slider bars, check boxes, etc. in OpenGL. Ideally, something that is not directly coupled with OpenGL is best (ie. so that I may replace the rendering with DirectX if need be).

My 'ideal' library would have an event system that supports callbacks or something similar. This is a nice-to-have, but not absolutely required.

I looked into Qt and wxWidgets and both seem very heavy. CEGUI looks like a mess of code. Most other libraries I seen are GLUT based.

tshepang
  • 10,772
  • 21
  • 84
  • 127
MarkP
  • 3,868
  • 9
  • 39
  • 76

3 Answers3

5

There's Dear IMGUI

https://github.com/ocornut/imgui

IMGUI

IMGUI

It's completely graphics API agnostic. It just builds vertices. Its up to you to render them.


There's also nuklear inspired by Dear ImGUI.

Nuklear

Nuklear

gman
  • 83,286
  • 25
  • 191
  • 301
2

You might want to have a look at a game engine such as Irrlicht which provides OpenGL, DirectX and Software renderers and supports a 2D GUI System with Buttons, Lists, Edit boxes. See the feature page to learn more about its capabilities and the user interface sample to try this specific UI feature.

Irrlicht is open source and works on many platforms. From the feature page it supports:

  • Windows 98, ME, NT 4, 2000, XP, XP64, Vista, CE
  • Linux
  • OSX
  • Sun Solaris/SPARC
  • All platforms using SDL
jonjbar
  • 3,588
  • 22
  • 44
  • Seconded, though you'll have to mess with IrrCompileConfig.h to get rid of all the 3D stuff (mesh loaders, video drivers, scene manager etc) – Gareth Davidson Sep 09 '11 at 15:20
2

Neither wxWidgets nor Qt draw in OpenGL; they don't use OpenGL rendering commands to draw. They allow you to create OpenGL windows, but the regular GUI controls (buttons, lists, etc) are not drawing through OpenGL. They're drawn through the native drawing mechanism of your platform of choice.

You are generally not going to find very many standalone GUI libraries that actually do their rendering in OpenGL. The only one I know of is CeGUI, which fits all of your requirements but you dismissed as being "a mess of code." Everything else is generally going to be "heavyweight", because it's part of a game engine.

Now, if you're not looking for something that actually draws using OpenGL commands, but is simply something that you can use alongside an OpenGL window, then things open up somewhat. However, your dismissal of wxWidgets as being "very heavy" is disconcerting, because GUI libraries aren't really going to get much lighter weight than that. A good GUI system requires a lot of stuff.

The smallest cross-platform GUI library that supports making an OpenGL window is probably FLTK. And even that's pretty big.

Nicol Bolas
  • 378,677
  • 53
  • 635
  • 829
  • Qt 5 will be using Lighthouse (i.e. OpenGL ES 2) for all of its window rendering. But the stable release will be a couple of months away to 1 year. – Afriza N. Arief Sep 09 '11 at 11:49
  • Glgooey was a quite good cegui alternative, although chronically under maintained these days. – Flexo Sep 09 '11 at 12:00
  • You are wrong. Qt draws in OpenGL. Qt starting 4.5 can draw OpenGL using OpenGL Graphics System. See Qt's Graphics Systems for more info. – happy_marmoset Sep 04 '13 at 15:45