Sign in to follow this  

Game Gui's

This topic is 4724 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
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
Quote:
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.


I've noticed that same thing. Those are GUIs where the interface in completely different looking on every screen and is more about presentation than function. If you hack into the resources folder and snoop around, i can sometimes find images for each of the games individual buttons, things like that. Definately the more hack-n-slash, art-driven approach.

@Omaha.

That looks awesome. Want to release the code?

Share this post


Link to post
Share on other sites
A big deal for GUI's in pro game development is also to make sure all the strings are localizable, so they're not burned into graphics. No artist wants to redo their button images in German, Spanish, Japanese, etc... So all the strings are stored as tags, for which the actual localized text is rendered after being fetched from a lookup table.

Most game engines have a menu and GUI system, although the complexity depends on the requirements for the game. The GUI in the Source Engine is very nice, I think, since it's simple, clean, and is easily editable via scripts. The game I'm working on now has an enormous number of menu screens, and custom controls all over the place. It's a nightmare to work with, not only because of the size, but because it's running on an XBox, so it's a challenge to keep the art assets in RAM under 64MB.

You may want to look at the FreeType Project ( http://freetype.sourceforge.net/index2.html ) to do your font rendering, if possible, since that may be the hardest part. The windows and popups are relatively easy in comparison.

Share this post


Link to post
Share on other sites
I've been designing a custom GUI for all my future projects. My latest implementation ties the GUI directly into the rendering pipeline, so my controls are rendered in the same manner as the rest of the game's sprites, including animation and whatnot. I used Visual Basic as the basis for my design; indeed, the GUI is event-driven and has much of the same functionality as VB controls. It renders through Direct3D, and everything is drawn using prefab textures. I don't have localization concerns at the moment, but this is something to consider for the future.

At the moment, I'm trying to determine how I can integrate my custom GUI with a virtual machine, so I can script the interface.

Share this post


Link to post
Share on other sites

This topic is 4724 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this