Jump to content
  • Advertisement

Archived

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

Jonus

OpenGL How do i start my own OpenGL GUI?

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

How would i design a gui? How does this message queue thing work? What classes will i need? I an working on an startegy game, and i need imput on how to do my gui right!

Share this post


Link to post
Share on other sites
Advertisement
heres a quick sample. no guarantee on it working, or being good. just ideas. I hope this helps.


class Button{
public:
//give it variables
float left,right,top,bottom;//relative to window
char *name;
//and a callback function
int (*fn)(void);
}

class Window{
public:
//give it variables
float left,right,top,bottom;
char *title;
int nButtons;//number of buttons
Button *buttons;//pointer to buttons in this window
//and functions like:
void Load(char* file);
void Draw();
}

Share this post


Link to post
Share on other sites
Still need more info on that message queue thing...

@robirt
Ok that helps a bit, but what's a call back function?

[edited by - Jonus on August 13, 2002 8:20:52 AM]

Share this post


Link to post
Share on other sites
I have also been working on some GUI-Elements like Buttons and Scrollbars which are implemented with OpenGL. I can tell you how I have designed that things. First I have introduced a common Baseclass which i named GraphicObject. This class contains all attributes and methods every Graphical Object have. Then there are some specific basical Graphical-Objects Classes which are inherited from the GraphicObject-Class, like a simple Line or a Rectangle and so on. Then I introduce a Composite-Class which contains of many different GraphicObjects(Here I use the Composite-Pattern for Details see E.Gamma,... "Design-Patterns"). A button or another GUI-Element is a Composite of different GraphicObjects like lines, rectangles and so on. So I created a Button-Class which inherits the Composite-Class.
For the Message-queue thing I use the Chain of Responsibility-Pattern (also see E.Gamma, ... "Design-Patterns" for more Details). That means that every GUI-Element has a method like HandleEvent() which get the Input like Windows callback Function and inside this you can Handle every Event. Do this for every GUI-Element and even the Window-itself(The Window is a composite of other GUI-Elements). For setting-up the Messagequeue call in your Windows-Main Function the HandleEvent()-Functions of your Window(s) which delegates the Event to their Child-Objects.
This is one Idea how you can implement your GUI in OpenGL. It is not an easy things and maybe there exists easier Designs. Look at www.OpenGL.org there exists alrady some GUI-Interfaces for OpenGL perhaps to use such an Library would be easier as implementing your own GUI.
Good luck

Peter Gmeiner

Share this post


Link to post
Share on other sites
a callback function is a function you set up to be called by another function, to answer both questions, the messages sent to you by your OS are usually handled by a callback function. In windows, when youre setting up your window class, you specify a function that will be called everytime you need to deal with a message you get from, and code that function accordingly. For a rundown on the whole thing, go to www.winprog.org and/or www.gametutorials.com

Share this post


Link to post
Share on other sites
Thanks guys!

@PGmeiner
I will take a close look at the design patterns your taleked about!

The case study at the beginning of the book is very intressting too.

@digitec devil
I still don''t understand what a ''callback'' function is, but i guess i will make it without it.

They''re function pointers in c and virtul in c++, thats all i understand until now.

@Michalson
I will check it out, ... cool that i can program a bit dx ... and yes i skiped part 1 .

Bruno
I will take a look at his source, but i don''t think thats his stuff is what i am looking for.

Share this post


Link to post
Share on other sites

  • 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!