Game Gui's

Started by
11 comments, last by Tom 19 years, 3 months ago
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?
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.
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
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
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).
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.
enum Bool { True, False, FileNotFound };
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).
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...
Killers don't end up in jailThey end up on a high-score!
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.

Everything is better with Metal.

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.


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

This topic is closed to new replies.

Advertisement