PDA

View Full Version : Perspective view is a mess up with depth testing.... ????



pedrodx
02-23-2005, 05:23 AM
Hi all!! I have a 3d scene, and when I apply an orthographic projection, depth testing occurs well, but when I apply a perspective projection, by example the triangle becomes invisible!!!
Detail: I apply camera viewing transforms, but I'm remodeling it to simple rotation/translation transforms (it is modelled only with gluLookAt)..... Could you please answer me this question, and in case of a mess up, (need to do with ortographic), do I need to do the near/far motion by glScale?? Thanks in advance!!

CWiC
02-25-2005, 02:07 AM
How did you apply perspective projection? It is more likely that you use wrong projection than you problem is depth buffer related.

pedrodx
02-28-2005, 05:44 AM
hi! I apply perspective projection by a call to
gluPerspective(90, 1, -100, 100); By the way.... Thanks!!

Relic
02-28-2005, 06:33 AM
Of course this doesn't work. The zNear parameter in gluPerspective must be greater than zero.
Try this
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0, 1.0, 1.0, 201.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -101.0f); // Puts the origin into (zFar + zNear)/2.0