Sign in to follow this  

Changing znear and zfar every frame

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

This topic is 3464 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this