Dynamic near and far clipping?

Started by blue_tomato, July 21, 2006, 11:21:35

Previous topic - Next topic

blue_tomato

I need to dynamically adjust the near and far z clipping values while my game is running, but how?

I am calling gluPerspective  and glFrustum, but only the first initial call seems to have any effect?

djork

You are probably in the modelview (i.e. rendering) matrix when you call those functions.  You need to go back into the projection matrix to re-adjust the viewport.

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();

// reset your view here

GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();

// back to rendering!

blue_tomato

Quote from: "djork"You are probably in the modelview (i.e. rendering) matrix when you call those functions.  You need to go back into the projection matrix to re-adjust the viewport.

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();

// reset your view here

GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();

// back to rendering!

Thanks a lot :)