Jump to content
  • Advertisement
Sign in to follow this  
OffbeatPatriot

OpenGL Drawing a hud

This topic is 3601 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'm working on a 2d game, I can draw my world and now I want to draw my hud, so far I have it set up to show me the regions where I plan to put everything and a little fps counter in the top left corner. Unfortunately things are complicated by the fact that I have a zoom feature that works by changing the height and width of glOrtho, basically the viewport stays the same while I project a bigger or smaller portion of the world on to it. To draw the hud properly I do some math to properly scale everything so it will stay glued to the view port, but I guess because of some rounding problems the hud wobbles ever so slightly when I zoom. If I intend to keep the zoom in the game and don't want the wobble effect is there any opengl feature and/or math I can use to do this? If I have to drop my plan of changing the height and width of the ortho view could I simply increase or decrease the near value of the ortho view to achieve a zoom?

Share this post


Link to post
Share on other sites
Advertisement
I think you can just set a different projection for the hud. That is, when you draw the world, you call glOrtho()/gluPerspective()/whatever with one set of values, and when you draw the hud you call a similar function with another set of values. That way the hud will not be influenced by the world's projection.

Share this post


Link to post
Share on other sites
Sign in to follow this  

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