Advertisement

far clip plane in Nehe base code (easy question!)

Started by November 17, 2004 02:55 PM
5 comments, last by Dvad78 20 years ago
Hey. Using the latest Nehe basecode. I notice the far clip plane on the default gluLookAt() frustrum is too short. A lot of stuff gets clipped off at a distance. How do I extend the frustrum? Here's what i got that's relevant: BOOL Initialize (GL_Window* window, Keys* keys) { glClearColor (0.0f, 0.0f, 0.0f, 0.0f); glClearDepth (1.0f); glDepthFunc (GL_LEQUAL); glEnable (GL_DEPTH_TEST); glShadeModel (GL_SMOOTH); glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); return TRUE; } void Draw (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); gluLookAt(CAMERA.x, CAMERA.y, CAMERA.z, LOOK_AT.x, LOOK_AT.y, LOOK_AT.z, WORLD_UP.x, WORLD_UP.y, WORLD_UP.z); // draw everything glFlush (); }
gluLookAt has nothing to do with the frustum. You need to change the last parameter in your gluPerspective call (or maybe glOrtho/glFrustum depending on which you actually use).

Enigma
Advertisement
I dont use either. All relevant code is posted above. Ahh so I guess I need to use gluPerspective eh? I'll try it out.
Are you talking about things being clipped at the far plane? If this is the case wouldnt raising the clear depth do the trick?

i.e.
glClearDepth (2.0f);
no depth is cliped between 0 and 1.

the func resizeGL contains this line.
gluPerspective (45.0f, (GLfloat)(width)/(GLfloat)(height),1, 1000.0f);

the last two parameters are znear and zfar.
zfar is the one you want to fiddle with.

Allso make shure that you choose a good scale.

A good rule is znear=1 meter, but this can be adjusted a little depending on how near things will be to the camera.
Just to clarify gluPerspective is already in the basecode (a quick shearch should solve your problem).

Cheers,
- llvllatrix
Advertisement
Ok, I think i understand now :) Thanks lc. (Obviously i am relatively new to OpenGL programming)

This topic is closed to new replies.

Advertisement