in some project we tried to do something like this:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 1.33, 1.0, 120000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(500, 200+playerTeam->teamAvatar->pos.y*0.1, 500, 0, 0+playerTeam->teamAvatar->pos.y*0.1, 0, 1.0, 1.0, 1.0);
glRotatef(this->angle, 0.0f, 1.0f, 0.0f);
glTranslatef(-pos2[0],-pos2[1],-pos2[2]);
// Draw some objects
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 1.33, 500.0, 120000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(500, 200+playerTeam->teamAvatar->pos.y*0.1, 500, 0, 0+playerTeam->teamAvatar->pos.y*0.1, 0, 1.0, 1.0, 1.0);
glRotatef(this->angle, 0.0f, 1.0f, 0.0f);
glTranslatef(-pos2[0],-pos2[1],-pos2[2]);
// draw some other objects
glDisable(GL_LIGHTING);
to get the effect of trimming objects between viewer and main character (its a third-person-view game). Of course it works fine, until we realise that there are problems with z-buffer testing (caused by changing zNear value) sothat trees on other side of hill are visible instead of the hill itself.
Is there a possibility to block affecting z-buffer values while re-setting gluPerspective’s zNear value?