LWJGL Forum

Programming => OpenGL => Topic started by: blue_tomato on July 21, 2006, 11:21:35

Title: Dynamic near and far clipping?
Post by: blue_tomato on July 21, 2006, 11:21:35
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?
Title: Dynamic near and far clipping?
Post by: djork on July 21, 2006, 13:29:46
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!
Title: Dynamic near and far clipping?
Post by: blue_tomato on July 22, 2006, 11:38:48
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 :)