I’m using the method below in a 3D viewer. This code comes from an Apple Developer example. I’m having a problem where objects seem to clip (all or part of the object becomes invisible when the camera is moved), and I can’t get a handle on why exactly. I believe it is related to the clipping plane variables “near” and “far” but it doesn’t seem as clear cut as just that. I’m not sure what the variable “shapeSize” is intended to do exactly, but this too seems to play a role in the problem. shapeSize = 7.0f; is Apple’s default for that var.
Anyone have any ideas? Thanks!

(void) updateProjection
{
GLdouble ratio, radians, wd2;
GLdouble left, right, top, bottom, near, far;[[self openGLContext] makeCurrentContext];
// set projection
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
near = camera.viewPos.z  shapeSize * 0.5;
if (near < 0.00001)
near = 0.00001;
far = camera.viewPos.z + shapeSize * 0.5;
if (far < 1.0)
far = 1.0;
radians = 0.0174532925 * camera.aperture / 2; // half aperture degrees to radians
wd2 = near * tan(radians);
ratio = camera.viewWidth / (float) camera.viewHeight;
if (ratio >= 1.0) {
left = ratio * wd2;
right = ratio * wd2;
top = wd2;
bottom = wd2;
} else {
left = wd2;
right = wd2;
top = wd2 / ratio;
bottom = wd2 / ratio;
}
glFrustum (left, right, bottom, top, near, far);
}