I want to change the setting of the near clip when drawing different parts of the scene so that certain parts of the scene are clipped and other parts are not clipped.
I tried this…
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLfloat) 640 /(GLfloat) 480, nearPlaneDist, 100.0f);
glMatrixMode(GL_MODELVIEW);
but it isn’t quite working correctly. My question is: Can I just call gluPerspective anywhere in my code? Or do I have to always call gluPerspective first, before doing any transformations? I guess I might need to do something like this…
glGetFloatv(GL_MODELVIEW_MATRIX,savedMatrix);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLfloat) 640 /(GLfloat) 480, nearPlaneDist, 100.0f);
glMatrixMode(GL_MODELVIEW);
glMultMatrixf(savedMatrix);
Is there an easier/better way to do this? Thanks in advance!