View Full Version : glortho and depth buffer

07-20-2005, 04:49 AM
I am using opengl on Windows XP. The program is developed in Compaq Visul Fortran version 6.6. In my application I switch beteen perspective and orthografic projection with the following code:

if (projmode .eq. ID_PROJ_MODE_PERSP) then
call fgluPerspective(vAngle,aspect,znear,zfar)
call fglTranslatef(xor,yor,0.0)
ytop =-yor+dify
ybtm =-yor-dify
xrght =-xor+difx
xleft =-xor-difx
call fglOrtho(xleft,xrght,ybtm,ytop,znear,zfar)
end if

In the perspective view the depth calculation works fine and round surfaces looks smooth (see figure 1), but in the orthografic view the depth calculation seems wrong (see figure 2). Is there extra calls or parameters to set in order to get the orthografic projection to work?

Figure 1: Perspective view

Figure 2: Orthografic view

07-24-2005, 08:44 PM
I have solved the problem my self.
The structure in the example is 10 by 10 by 10 and are seen in distance 100. In my program znear = 1 and zfar = 10^20 and this works fine for perspective views, but in orthografic views the very large zfar destroys the precision in the depth calculation. If zfar is changed to 200, all works fine.