3D Objects' Depth Problem

Hi,

I am trying to draw a room by drawing a bunch of polygons. I would also like to move around the room. I have managed to do these successfully but the problem is when I move around, the walls flicker and disappear. I understand there is a problem with my gluLookAt’s zNear and zFar but how do I fix it as I move? btw, this code is an update by frame rate per second… so it is updates like 10 times per second or whatever is chosen.

code is roughly like this

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60*zoom, 1.0, 0, 1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eye[0], eye[1], eye[2], at[0], at[1], at[2], v_up[0], v_up[1], v_up[2]);

glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);

// load and draw all polygons and disable depthtest and cull face…

thanks in advance

K

You might want to push that zNear out a bit. Try something like zNear=1, zFar=100.

Here’s the spec on that function:
http://www.mevis.de/~uwe/opengl/gluPerspective.html

And, more importantly, here’s what it’s based on:
http://www.mevis.de/~uwe/opengl/glFrustum.html

Note how the depth quality can be roughly measured by the ratio near/far.