Simple GUI suggestions

Started by
9 comments, last by RobinsonUK 12 years, 2 months ago
Hi all.

I'm working on a game that uses OpenGL for the graphics and SDL for input. It will require a really simple GUI, such as one with buttons and text boxes (nothing that advanced). What would you suggest for either a UI library I could use, or even tutorials to use to create this simple UI in OpenGL?

I've tried a variety of libraries so far, and a IMGUI tutorial for SDL, but they all seem much too advanced for what I need them for and require too much time to learn, when all I want is something very basic.
Advertisement
If you only need buttons and textboxes then you can easily implement it yourself (its just drawing quads basically so no need for a tutorial there), If you need more advanced controls then you'll have to bite the bullet i guess, or pay for something like scaleform.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
I'm working on one for my game right now. In fact I came here today to ask a design question about GUIs. You may wanna keep an eye out for my thread, it may have useful info for ya if you wanna make your own. wink.png
I don't know about SDL, but SFML has sfgui (http://sfgui.sfml-dev.de/) which runs on SFML. You can use SFML with OpenGL as well if you want. If sfgui is too much for you, then, ya, I'd just make your own.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)


class UIObject
{
void HandleMouseClick(int x, int y, int button)
void HandleMouseMove(int x, int y)
void Draw();

int x, y, width, height
}

//Somewhere
UIObject[] objects

//On mouse click somewhere in your code
foreach UIObject o in objects
o.HandleMouseClick(x,y,b)


//On mouse movesomewhere in your code
foreach UIObject o in objects
o.HandleMouseMove(x,y,b)


//OnDraw somewhere in your code
foreach UIObject o in objects
o.Draw()


Your button and text ui object would inherit from UIObject and override the handle methods. You could then raise specfic events in your derived classes that relate to that type of ui object, eg scroll bar could have 'onscroll', button could have 'onclick'.
Awesomium is a great gui framework. It is built on top of chromium. If you have experience with web design languages (html, css, js), that will make your life way easier. Integration might take some time but its worth it.
What about using QT for gui?
Just could simply create a screenshot of the gui created by QT and use it in your game.

I don't know how well that works, but it works well in theory :P

Visit my blog, follow me on twitter or check out my bitbucket repositories.

I think it would be quicker to write your own button/text box implementation than to learn a new GUI like QT, for sure :P.

Awesomium is a great gui framework. It is built on top of chromium. If you have experience with web design languages (html, css, js), that will make your life way easier. Integration might take some time but its worth it.


There is also a free variation of awesomium which you can find here: http://berkelium.org/
And an other one here http://code.google.com/p/chromiumembedded/

And yes, It's worth the effort.

Best Jochen
Why did Doug Gregor create the empty directory?

I think it would be quicker to write your own button/text box implementation than to learn a new GUI like QT, for sure tongue.png.
Except for something really trivial, I would say learning a new GUI toolkit is much faster than rolling your own GUI system (and I wouldn't put textboxes as being trivial). I was coding Qt apps in hours, and adding a textbox is just a matter of looking up the API.

Perhaps it would be longer if you have no previous experience of GUI toolkits - but then if that's the case, you're going to struggle rolling your own anyway, and I'd recommend first learning something like Qt anyway just so you can get some experience of how GUIs should be implemented smile.png

Not that I'm suggesting that here - the problem with this kind of approach is that it won't appear inside your graphics window, which is what games usually want (and I don't see how taking a screenshot would help create a working GUI).

http://erebusrpg.sourceforge.net/ - Erebus, Open Source RPG for Windows/Linux/Android
http://conquests.sourceforge.net/ - Conquests, Open Source Civ-like Game for Windows/Linux

This topic is closed to new replies.

Advertisement