PDA

View Full Version : OpenGL Depth Problem


Twib
03-24-2005, 02:20 PM
Hi, hope someone can help, I have a small problem in an application I am working on. The problem is the depth culling that openGL does. I need to use a larger frustum, as my object keeps dissapearing out of the back way too easily. I know it is possible to do this, and I've been studying the OpenGL Programming Guide, which recommends that I use either the lines:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.6,1.6,-1.2,1.2,6,18.0);
glMatrixMode(GL_MODELVIEW);

or

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, 1.333f, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);

I have substituted into both of these some values I thought were appropriate, in the glFrustum() the values I worked out based on my distance from the monitor etc. and the gluPerspective() the values were pretty much taken from a NeHeGL tutorial program, where they seem to work fine. The problem I have is that with these lines in place my program only renders a black screen! Have I got some values wrong? Is there a way to just change the far plane of the frustum without arsing about with the rest? The project is to basically have a fish swimming around, but with the frustum as it is at the moment, there isn't really alot of space for the fish to swim in!

Thanks for your time
Twib

Ch3
03-24-2005, 11:48 PM
Generally you need to keep the range between the near and the far clipping plane relative small. So as you puch back the far clipping plane, you need to increase the near one as well a little bit. The distribution of the xDepth range tho is exponetial, because you need a greater accuracy close to the camera.
Some graphics cards have 8bits other have 16 for the zDepth. I was making a game using an ATI, and when I tried it out in a gForce, I freaked out cause all my objects were half visible.

I dont remember the syntax of the openGl functions... and the values are always relevant to your scene.
I am not sure if that will help you.

CGTalk Moderation
03-24-2005, 11:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.