Jump to content
  • Advertisement
Sign in to follow this  
NoKKiE

OpenGL gluPerspective performance issues?

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

Hello, I am pretty new to OpenGL but I had a really quick question about gluPerspective. Do I have to worry much about this function causing performance issues if I am calling it a lot? In order to capture more precise mouse movements with gluUnProject/gluProject I have to temporarily set the near and far clipping planes to ones that are easier to calculate the depth. I basically have 2 options, either calculate what the depth really should be given the current planes whenever I need to project or unproject... or set the easy ones, get the projection, and set it back. Which solution would be better? gluPerspective seems to be a really easy routine but I have no idea how it is implemented internally. Is it common practice to call gluPerspective to create easier calculated values?

Share this post


Link to post
Share on other sites
Advertisement
If you are worried about the performance of gluPerpective, you can call it once, retrieve the matrix it generates (using glGetFloatv(GL_PROJECTION_MATRIX) ), and then upload that matrix (using glLoadMatrixf) whenever you need it.

In general though, gluPerspective is fast enough to be called many times each frame without problems - all it does is a little math, after all.

Share this post


Link to post
Share on other sites
gluPerspective is a few lines of code. It computes the left, right, bottom and top and calls glFrustum. I suppose if you call it a few thousaud or 10,000 times per scene it might slow things down.

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!