Changing znear and zfar every frame
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
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.
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.
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?
Regarding your question:
When do you call gluPerspective?
Did you call glMatrixMode(GL_PROJECTION) before calling gluPerspective?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement