Hello Guest

Dynamic near and far clipping?

  • 2 Replies
  • 5044 Views
Dynamic near and far clipping?
« 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?

Dynamic near and far clipping?
« Reply #1 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.

Code: [Select]

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

// reset your view here

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

// back to rendering!

Dynamic near and far clipping?
« Reply #2 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.

Code: [Select]

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

// reset your view here

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

// back to rendering!


Thanks a lot :)