OpenGL GUI anyone? Updated on 11/17/05

Started by
206 comments, last by Alpha_ProgDes 17 years, 10 months ago
Quote:Original post by OpenGL_Guru
Quote:If you figure out how to implement a timer in Linux and manage to modify my Tools/FPSCounter and Tools/Timer, you're gold


UGHH -- well in linux i really dont care about the FPS counter or keeping track of the FPS counter.


im gonna work on it and try things out though....

also gonan look at the GLUT version you have there.. oh yeah if you still need that favor, whatever that is, lemme know :)


The Timer is crucial for the subtle fading effect that you're seeing in the GUI, as a matter of fact I need to measure the time interval from one frame to the other and provide the GUIFrame with it at rendering time.
Advertisement
ahhh i see... ok then...hmm.. well i will have to look into that then...

i guess you couldnt simply use an alpha for the transparency of the texture and just do a increment or decrement to make it opaque or transparent.. cos some computer will render slower or faster...

just out of curiousity did you try doing a GUI like this in just plain 'ol openGL? like just drawing the quads and buttons all in straight openGL. of course you would have to keep up with everything located in ortho mode i would assume.. i dunno.
heh
Thanks for the quick tutorial. If I hadn't rated you up all the way already I'd do so now.

Unfortunately for me, the design of how to take action just doesn't appeal to me. I guess I'll just have to finish work on DaedalusGUI :D

Since you asked for other options, here's how I do it. The root widget is actually a kind of manager for the entire GUI (since I can have multiple OS windows, each window has it's own manager/root widget. You can register callbacks with the root like so:
guiRootNew.AddCommand(widgetPointer, GUI::MOUSE1_UP,	boost::bind(&GUI::IBase::ProcessMessage, base, GUI::HIDE, mMouse) );guiRootNew.AddCommand("testbutton2", GUI::MOUSE1_UP, boost::bind(&GUI::IBase::ProcessMessage, base, GUI::SHOW, mMouse) );guiRootNew.AddCommand("quitbutton", GUI::MOUSE1_UP, boost::bind(&Daedalus::Quit) );


So a combination of the widget you want to attach the callback to (although under the hood, it's stored with the root instead), the message that you want to react to, and a function object that will be called.

At the moment all widgets react to all messages, but I'm going to change that so images for instance don't react to button presses.

To me this design seems cleaner to use than the if/else statements you have. My design is comparable to a kind of signal/slot system as is also available in boost.
Quote:Original post by OpenGL_Guru
ahhh i see... ok then...hmm.. well i will have to look into that then...

i guess you couldnt simply use an alpha for the transparency of the texture and just do a increment or decrement to make it opaque or transparent.. cos some computer will render slower or faster...

just out of curiousity did you try doing a GUI like this in just plain 'ol openGL? like just drawing the quads and buttons all in straight openGL. of course you would have to keep up with everything located in ortho mode i would assume.. i dunno.


That is how I do it, pure OpenGL that is [wink]

Quote:Original post by rick_appleton
Thanks for the quick tutorial. If I hadn't rated you up all the way already I'd do so now.

Unfortunately for me, the design of how to take action just doesn't appeal to me. I guess I'll just have to finish work on DaedalusGUI :D

Since you asked for other options, here's how I do it. The root widget is actually a kind of manager for the entire GUI (since I can have multiple OS windows, each window has it's own manager/root widget. You can register callbacks with the root like so:
guiRootNew.AddCommand(widgetPointer, GUI::MOUSE1_UP,	boost::bind(&GUI::IBase::ProcessMessage, base, GUI::HIDE, mMouse) );guiRootNew.AddCommand("testbutton2", GUI::MOUSE1_UP, boost::bind(&GUI::IBase::ProcessMessage, base, GUI::SHOW, mMouse) );guiRootNew.AddCommand("quitbutton", GUI::MOUSE1_UP, boost::bind(&Daedalus::Quit) );


So a combination of the widget you want to attach the callback to (although under the hood, it's stored with the root instead), the message that you want to react to, and a function object that will be called.

At the moment all widgets react to all messages, but I'm going to change that so images for instance don't react to button presses.

To me this design seems cleaner to use than the if/else statements you have. My design is comparable to a kind of signal/slot system as is also available in boost.


Yeah I like that design of yours, post binaries and screenshots when you're done mate :)
I had to resort to callback strings in my GUI because in some of my unreleased projects I deal with a lot and lot of widgets, and frankly I'd rather load them all up from a separate file than hardcoding them.
Just a different approach brother [wink]

yah..i know you did it in openGL silly..as far as drawing the quads etc etc
but i mean without using xml to help you locate and define all the buttons, widgets etc etc. :)

btw -- i guess there is no mouseover/mousehover function for GLUT, unless its hidden under mousespecialfunc(); ?????

oh yeah about your timer..did you try using the glut TImer? that way it can be cross platform :)

heres the link to GLUT callback functions

Glut Callback Functions
heh
OpenGL_guru, I'm gonna have to look into that but unfortunately won't be able to do so until sometimes next week when I'm all settled down in Silicon Valley.
My next priority is fixing the text box and adding DropDown menus, List boxes and text areas.
Stay tuned.
PS: Any luck in porting the GLUT code to Linux anyone? Come on it shouldn't be tough [pig]
Alright off to catch my airplane [smile]
Quote:Original post by rick_appleton
Unfortunately for me, the design of how to take action just doesn't appeal to me. I guess I'll just have to finish work on DaedalusGUI :D

To me this design seems cleaner to use than the if/else statements you have. My design is comparable to a kind of signal/slot system as is also available in boost.


I also used to handle callbacks in this manner and I think this approach works very well if you want to hardcode a lot of the logic to a specific type of object (eg: you know that a Button will react to OnClick but a Label won't). With a little work, you could easily build a central message dispatcher that will delegate the messages out to the respective named widgets. If you send the message straight to the widget and let it be handled internally this should work quite well. Of course, it means that every widget will receive every message, which could result in a speed hit.




After alot of brutal messing around got it running on Linux.
Not untill it was to late I realised how to use GNU Autotools to in a good way(tm) to use the source structure JavaCoolDude used so I will need to redo it once I get some more free time (I flattened it and placed all .cpp and .h files in a src directory). And hmm, fix the mouse events cause at the moment they are not being sent to widgets properly so can't use any of the widgets really, bargh, but that should not be to hard to fix, just wanted to show of a screenshot running 2 instances of the GLUT test app on Linux before I went to bed.


Edit: My gosh I spell bad.
Have you got any tools for your source? Is it documented? Do you have some kind of an editor for your GUI?
Just curious, because how would you go about locating/positioning your GUI widgets around the screen? Do you use keyboard to move them or a mouse??

A cool looking GUI, can you do any animations with it, like for buttons??

Good work mate.

This topic is closed to new replies.

Advertisement