• Advertisement

Archived

This topic is now archived and is closed to further replies.

Game GUIs

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

Say you wanted to create a cool looking GUI for your game. Like me, you wanted to create your game using MFC instead of Win32. Now, would you attpemt to write skinning functions for those controls you will be using in your GUI, or would you use the GUI switchy thing in XP. If you used the XP switchy thing then you could only rtun your application on XP. What would you use to make a new game GUI with MFC?

Share this post


Link to post
Share on other sites
Advertisement
I wrote a nice OpenGL GUI that supports multiple windows, buttons, labels, text boxes, scroll boxes, etc... all can be seperately textured, or use a default texture, the background has a texture, all windows can have alpha maps and/or have an alpha value... windows are moveable too... more things to come soon too . New objects can easily be created by inheriting from my base object class, and filling in the required function (draw, mouse click, keypress, etc).

Share this post


Link to post
Share on other sites
one thing came to my mind right now. how are you scrolling your texts? i could imagine scrolling line by line and just changing the offset into the string. or rendering the whole text to a texture and only change the tex coords while scrolling.

Share this post


Link to post
Share on other sites
A GUI in OpenGL? How would you make something like this? May I see a sample or demo application of this OpenGL GUI? have never heard of a full GUI made in OpenGL before. I wonder how it is done. Please show me a demo of your applications.

Share this post


Link to post
Share on other sites
@sakky: Have you never played an OpenGL game where you typed in your name?

Share this post


Link to post
Share on other sites
OMFG.. i had it all typed, and it didn''t post, hit Back, and it was gone... lets try this one more time:

Image 1
Image 2
Image 3
Image 4
Image 5
Image 6
Image 7

These are my images from my work in progress opengl GUI. Written in MSVC 6.0 with opengl. Current objects are text boxes, command buttons, list boxes, and labels. Windows are draggable,a dn the command button currently swaps the text in both text-boxes when it''s clicked.

Share this post


Link to post
Share on other sites
Please let me know what you think, and what you''d like to see implemented. Also, if you want a demo of the .exe, let me know, and I will upload a more recent version.

Share this post


Link to post
Share on other sites
Please let me know what you think, and what you''d like to see implemented. Also, if you want a demo of the .exe, let me know, and I will upload a more recent version.

older version here

Share this post


Link to post
Share on other sites
Trienco: For my list box, I have a list of pointers (to strings), so I simply store the first object to display in the list, and use a for list to display to the number of items visible in the list box (you can set how tall it is to display more or less items in it at a time).

[edited by - Ready4Dis on February 3, 2003 12:00:59 PM]

Share this post


Link to post
Share on other sites
ah.. was curious if you adapt the strings to the box/window or do something else. its probably not worth the effort, but im thinking about a way that lets you scroll "smoothly" through text while confining it to the box (while still be simple and straight forward). rendering the text into a texture and just moving over it might work, though i dont know if that would be a practical approach.

Share this post


Link to post
Share on other sites
I was thinking about adding smooth scrolling... but to much hassle for now. I am converting it over into 2d, where I have a lot more control over how things are drawn. The purpose of this GUI was to test designs for an OS i''m writing. It will end up being 2d, with all sorts of alpha tricks, smooth scrolling, etc.. but for now, i''m just making it work, and error free .

Share this post


Link to post
Share on other sites
I have played a game with OpenGL GUI. Now how do I build one? Do you guys make the frame work from the ground up? Or do you use part of Windows frame work with a few twist? I was thinking about doing something with the Windows GUI and adding my interface to it.

I would like to see some source code and exe demos of some OpenGL gui or any gui system of you guys. I would also like some links to tutorials. Google doesn''y bring up thr right stuff.

Share this post


Link to post
Share on other sites
I wrote it from the ground up, and I linked a demo with source code for you. It''s not as complete as a windows GUI, but it sure can look pretty . If you are really interested in the code, I have to ask if you''re familiar with linked lists, and class inheritance... if not, you''ll be completely lost, as the entire thing is based around this .

Share this post


Link to post
Share on other sites
Here's a GUI i've been working on:

ScottEngine GUI (right click and Save As)

Although i cannot claim that it will work seeing how i've never tried it on anything other than my computer, but i'm confident. You also might notice if you try it that it's not 100% yet, but it does what it's supposed for the most part, and i'm quite proud of it. Also, please do not laugh at my code. it may not be heavily comment, but it's not too hard to follow IMHO. App.cpp contains the code that creates the windows, and GUI.cpp contains the action code for the windows and controls in the two functions:

void CGui::Action(...)
void CGui::UpdateControls(...)

i think.

Also, the Gui code was coded by myself 100%, as for some of the other code in other files, i cannot claim responability for all of it. It uses a modified NeHe Basecode + various other sources. The directInput stuff comes pretty much straight from OpenGL Game Programming , and i can't remember what else at the moment, but i'll soon get all that in the readme.txt.

This actually the first time i've released any of this... to anyone, so if it does work, let me know

Scott


------------------------------------------------------------
Email
Website

"If you try and don't succeed, destroy all evidence that you tried."
------------------------------------------------------------


[edited by - wojtos on February 3, 2003 10:05:56 PM]

[edited by - wojtos on February 3, 2003 10:06:54 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by sakky
I have played a game with OpenGL GUI. Now how do I build one? Do you guys make the frame work from the ground up? Or do you use part of Windows frame work with a few twist? I was thinking about doing something with the Windows GUI and adding my interface to it.

I would like to see some source code and exe demos of some OpenGL gui or any gui system of you guys. I would also like some links to tutorials. Google doesn''y bring up thr right stuff.



i would expect a) trouble to even render windows gui in an opengl viewport and b) more work to stop them looking like windows than it would take to code your own ,-)

Share this post


Link to post
Share on other sites
Wojtos and Ready4Dis, I can''t download either of your samples - I''d like to see them.

Share this post


Link to post
Share on other sites
Currently my GUI supports passing input messages via the virtual function method, propogating the message down through to the bottom window, or control. Even this method is simple, anyone have any thoughts as to how microsoft handles messages? I know that they have some member function macro system set up that binds the functions, and decreases the overhead by eliminating the messaging handling functions that arent needed. This is comletely different than how I do it, in that every child window musta also contain all of the window handling routines.


so in my setup i have a generic window that has message functions like this:

window->mouse_dblclick();
window->mouse_rightclick();

etc...

and every window will inherit those same member functions, and I can fill them in to make them handle differently for each dialog, button, etc. that inherits. This is wasteful though it seems, to inherit all that data.


microsoft seems to only have those handling functions defined when needed within any arbitrary window. I dont understand how they add message handlers without all the inheritance. Anyone shed some light on this subject? My guess is they have function pointers or something within the base class declaration, and then they are bound to real member functions via these macro things when needed. I dont know tho, but somebody does.

Share this post


Link to post
Share on other sites
Famine: Each time it is "inherited" I don''t beleive that it actually makes a copy of the functions, it just creates one instance of the function, and passes the "this" pointer to said functions.

Xori: Email me, or find me online... (could you at least view the images?)

Email: Ready4Dis@aol.com
AIM: CrazyGuy4Eva
MSN: Ready4Dis_1@hotmail.com

Share this post


Link to post
Share on other sites
Wojitos: After reading through a few lines of code, I think I''m sick . You check EVERY single key to see if it''s depressed?! Also, some buttons are in front of windows that are above them, which looks rather odd. Also, your window class handles your object''s getting clicked, etc... while I have my objects handling what happens when they are clicked. I also noticed that you check EACH object type in seperate loops.... I have a base class object, that each object is inherited by, so I can simply check my single linked list (linked lists are much better for this, because you don''t have to re-allocate memory, copy objects, and delete old memory.. you simply allocate the new block of memory, and update the pointers.) You''re code would be VERY difficult to add new objects too, as you''d have to go through and implement you''re object code within your window code, add extra loops, etc. With mine, you can add new objects without modifying my code base AT ALL. You simply inherit from the base class, create the object you''d like (with functions to handle KeyPress, MouseClick, and a few other actions), make a call to my window class'' Add_Object with a pointer to your object, and it will automagically handle it . No need to implement more loops, or other types of handling things, and no need to even understand any of my underlying code .

ps. This is meant to be constructive, if it comes off as me picking on you, sorry . I am going to finish up on writing this section of code (I was writing some debbuging code) and then I will make the sources available to anyone interested.

Share this post


Link to post
Share on other sites
I’ve been working on a GUI in my side project, I’m not normally a graphics programmer so this has been fun for me. I opted to create my GUI using nothing more than quads and lines. There aren’t any textures – the result is something that looks similar to the Amiga’s GUI (Workbench 3.0) or maybe even Rollercoaster Tycoon’s.

The interesting bit is that I had started out creating derived objects, just as most of you have described, but I am now thinking of creating one Gadget class (akin to the way the Amiga’s OS did). Basically, you have flags that let you set the type of gadget that you are creating or dealing with. Looking through the Amiga ROM Kernel manual at the simple structure it seems almost perfect for a game.

I know the lack of using texture may sound lame but it really is a nice look so far… I’m curious, as I said I’m not a graphics programmer, but would this type of rendering be faster than that of using textures? I would think the answer to be yes especially if I convert the rendering code to utilize vertex arrays.

Any thoughts?


Dave "Dak Lozar" Loeser

Share this post


Link to post
Share on other sites
I''m sorry to inform you, but no, it''s probably not faster. It''s faster to render one textured quad, then to render a few lines + quads without textures (unless of course, you''re very short on graphics memory, and it has to go across the AGP/PCI bus). My GUI uses 3 quads per window right now, how many quads + lines per window? (Also, I only use 1 quad per object, and 4 other quads for highlights, but that may be switched to lines, not sure). Also, a lot of graphics hardware doesn''t have accelerated line drawing functions built in, so it may actually be a LOT slower .

Having a flag won''t do much for you, unless you can define what each flag does. I can add an object type into my project without modifying ANY code at all, just add the new class and call the Add_Object function with a pointer to your object, and it handles it automatically. There isn''t a good way to do that with widgets (not that I know of), I can release this as a compiled library, and people can add their own object types without the need to even have my code.

Share this post


Link to post
Share on other sites
Ready4Dis - I don''t understand linked lists very well, so i work with what i have how is it you structure your controls and windows? thanks for picking at my code, i know it''s pretty bad, but you gave me a lot to think about


------------------------------------------------------------
Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
------------------------------------------------------------

Share this post


Link to post
Share on other sites
Glad you took it the way it was meant to be (constructively).

My program is setup like this:

The GUI holds the windows, which holds the objects. When a message is received by windows (key down, key up, mouse down, mouse up, etc) it is sent to my GUI class, which in turn, sends it to the current window (if it''s a mouse click, it checks to see which window the mouse is over, and sets that as current). The window in turn, holds a list of objects associated with it... so when it receives an event, it passes it along to the current object (if it was a click, it checks to see if an object was clicked and sets that as current). The object can then do it''s thing using whatever code it has to handle such events. My command button class takes a function pointer, so when it''s clicked or spacebar/enter is hit over it, it calls the function that you passed it (so the command button code is generic, and you can do the specific stuff in the outside function).

When things are drawn, it is very similar also... my GUI class draws the background image, then calls each windows draw function which draws itself, then calls each objects draw function, which draws the objects. The order I draw the windows (last one first, first one last) makes the "current" window be on top, and the objects on that window are always drawn at the correct time (so windows over it, are always drawn over it, etc).

I am just adding a few touches to my code, so if you shoot me an email (Ready4Dis@aol.com) I will send you over my code to check out. Linked lists aren''t difficult to understand once you have the concept of pointers .

Share this post


Link to post
Share on other sites
Hey guys,

I have some questions regarding gui implementations - stuff that isnt covered in the tutorials on this site. Do you derive an actual "splash window" from class window and only have 1 object of type splash window shown at the start of a prog? or do u build up the window on the fly using local / static variables?
Also, how exactly do you handle messages? do you write a handler for each button, and if so where do you write it? in its parent window''s code? or as general (global) code? I can get from the stage of actual event to window/control recognising the event, but i am unhappy with what happens after that (ie say a button is pressed)?
cheers for any help.
Aface

Share this post


Link to post
Share on other sites

  • Advertisement