Jump to content
  • Advertisement
Sign in to follow this  
Lode

Game Gui's

This topic is 5007 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

Since in games you use OpenGL or DirectX or SDL or something similar, and you want it to run fullscreen and want the Gui to look smooth with the rest of the game, you can't use the standard Windows GUI. Do professional games have their code for the whole GUI? Like scrollbars and checkboxes and stuff, and windows that can be dragged. I made a GUI for my own game that supports almost anything I want except windows that can be dragged, and it looks like this at the moment: Image Hosted by ImageShack.us Both the font and the buttons are OpenGL textures. I had to make everything manually, checking if the mouse is on top of a button or checkbox or not, calculating the size of a button so the text can fit in it, moving around the cursor in the Input Line, allowing unicode style input, handling backspace, delete button and arrow keys for the Input Line, making a String Stack for the console, checking the length of words between spaces in a string for splitting text between words to make the lines fit inside the box, making panels that can have any size with tileble center, corner and side textures, etc... I'm wondering, was the creation of this GUI useful or not? Do you create your own GUI for your game this way?

Share this post


Link to post
Share on other sites
Advertisement
I'm sure professional developers create large systems to easily create menus. Look at the electronic arts games for example. They clearly use a similar system in all their games.

We've spent a few months in total on a pretty advanced window/menu system to be used in all our games in the future. I believe it will help a lot the next time around.

Take a look at the Roadclub demo I'm posting in this forum soon.

Share this post


Link to post
Share on other sites
Looks quite nice! Sadly, yes, it is necessary (in opengl, however, direct x has just started providing a GUI library for exactly that purpose, but i dont know how well it will catch on because, well at least for people like me, while i dont like reinventing the wheel, i still want to write some of my own code :-D ),still, i think many people do exactly what you have done

(id actually be curious to see how you did the font) :-D

anywho, hope that helps
-Dan

Share this post


Link to post
Share on other sites
Quote:
Original post by Ademan555
(id actually be curious to see how you did the font) :-D


I'm glad you asked :D

First of all, to allow the program to print error messages if it doesn't find any image, I have embedded the font texture into the exe file instead of loading it from an image.

To print text or numbers, I made a function that can draw a single character, and then a function that goes through every character of a string, drawing each character behind the previous one.

styles like italic and bold are done by playing with texture coordinates in OpenGL, and colors are easy of course.

Then there are more advanced printing functions, that can go to the next line and split text between words and stuff.

And there's also support for other fonts loaded from bitmap images, by using a pointer to a font, which is an array of 256 character texture objects (one for each ascii value).

Share this post


Link to post
Share on other sites
Most "pro" GUIS seem to be based on bitmap images for things like labels, buttons, highlights and glow. Artists have more control in Photoshop than you have in your GL code.

Also, for text output, I've found that you get best results with offscreen bitmaps where you draw TrueType fonts, and upload as a texture, for each text element. Using the single-font texture eats up too many vertices, and typically doesn't give you a good selection of font kinds, nor typographical controls like kerning and ligatures.

Share this post


Link to post
Share on other sites
Professional games absolutely write their own GUI systems (most of the time). I think you will find your GUI code to be extremely useful in the future. Just take care to make it data driven if possible and to be fairly modular so you can easily add new features, widgets (controls), effects, etc. It's also very useful to be able to easily swap out the backend (rendering, input, etc) for use on other platforms, moving from OpenGL to DirectX, and so on. And keeping it tightly coupled with the game is a bad idea as it limits reuse (like the poster above mentioned EA's GUI system being reused all over the place).

Share this post


Link to post
Share on other sites
You should take a look at the Quake 3 game source.
The GUI is included and the scripting part sounds like a good idea for extensions and such.
Anybody want to comment that?
Because right now I'm designing my own, and I've decided it to be scripted like Quake 3...

Share this post


Link to post
Share on other sites
GUIS are a proverbial pain in the ass. Doing it from start is a lot of work. Not complicated work, just hard work. That and all the different layouts, funky effects, multiple viewports and widescreen (I'm mostly talking console)... If you can use someone else's work, the better. Especially if you plan on doing extra dialogs like lists, combo boxes, trees, scrollbars, ... gives me the shivers.

Share this post


Link to post
Share on other sites
Looks great. Will you be open sourcing this on your website? I also made a gui library and I'm having some problems making a good(read: efficient) multiline text edit so I'd love to get a look at yours.

Share this post


Link to post
Share on other sites


Oh yeah, using the Zero Wing intro for GUI testing is totally where it's at :) (That pic is mighty old and very obsolete)

The GUI I developed for the previous version of that game was actually much more functional but behind the scenes, honestly, was a hack job. It had some good stuff though, draggable windows, multiple window support...


Early incarnation


Fancified and unlocked from resolution (mostly...)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!