Jump to content
  • Advertisement
Sign in to follow this  
Lex224

Simple GUI suggestions

This topic is 2498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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'.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!