Jump to content
  • Advertisement

Archived

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

JClayton

OpenGL OpenGL GUI

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

I am working on a GUI in openGL and I was thinking about just drawing quads onto the screen to represent menus. These quads would have relative positioning to the openGL window and would support blending, lightmapping, etc... I would manage these "windows" with a vector of somesort and would accept mouse input on the topmost windows. The only problem is... I need an algorithm to make sure that they "windows" (quads) remain at the same position on the screen (not the coord system) for movement on all axis. I''m not exactly sure the best way of doing this but I haven''t been able to think of any better solutions...

Share this post


Link to post
Share on other sites
Advertisement
I thought about using ortho for the GUI but I would then be forced to switch to perspective mode after the GUI was rendered... is there a significant overhead to this method or is it acceptable for a gaming engine.

Share this post


Link to post
Share on other sites
from what i can gather its teh general way its done (any other way doesnt make much sense, you''d probably be doing more work than a change of the persecptive matrix twice each frame).

Its really quite simple
- Render in 3D
- switch to projection matrix
- push matrix
- switch to Ortho mode
- switch to modelview matrix
- Draw 2D
- switch to projection matrix
- pop matrix
- switch back to modelview

Its even possible you could store the ortho projection matrix once on start up and then just load it into the projection matrix instead of recalculating it each frame (though i doubt you''d gain anything significant in speed)


[Phantom Web | OpenGL Window Framework ]
"i wonder why i do that... type words which are nuffin like the word i wanted every now and badger"

Share this post


Link to post
Share on other sites
There is no penalty as long as you do that once/frame (or even a few times/frame).
Everyone does it this way, since there is no other sane way to do it.

Share this post


Link to post
Share on other sites
quote:
Original post by Raduprv
Everyone does it this way, since there is no other sane way to do it.


it would hardly cause much headache to draw a gui with perspective projection. use a simple z=1, precalculate the with and height for z=1 and multiply with positions in percent.
but why bother if ortho is even nicer to use (just try and DONT use absolute positions unless youre app is supposed to run at only one resolution).

and overhead? changing the projection matrix shouldnt be any more or less overhead than changing the modelview matrix and you usually do that hundreds or thousands of times per frame.

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!