Jump to content
  • Advertisement
Sign in to follow this  
Bear777

Changing znear and zfar every frame

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

Hi, I'm using gluPerspective() for my perspective projection. I need to change the znear and zfar values every frame, so I can move closer to a certain object without any limits. However, only the znear and zfar in the first time I call gluPerspective() seem to matter. Can anyone help me (providing an alternative solution maybe)? Michel

Share this post


Link to post
Share on other sites
Advertisement
For zooming in you should only need to decrease the field of view. I don't understand why you need to change the near/far planes.

Share this post


Link to post
Share on other sites
Quote:
Original post by biggoron
For zooming in you should only need to decrease the field of view. I don't understand why you need to change the near/far planes.


Well, I actually meant moving closer.

Share this post


Link to post
Share on other sites
If I understand you correctly, you zoom in by moving the camera towards the object and you want to adjust the near and far clipping planes to avoid clipping at the near plane and depth buffer imprecision. What's wrong with changing the fov? You should get the same result with that.

Regarding your question:
When do you call gluPerspective?
Did you call glMatrixMode(GL_PROJECTION) before calling gluPerspective?

Share this post


Link to post
Share on other sites
You want to change znear and zfar so that objects don't clipped or because you want to zoom. Because znear and zfar have no effect on zooming.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lord_Evil
... What's wrong with changing the fov? ...


Changing fov for zooming is not a good idea. We should use gluPickMatrix for zooming instead.

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!