PDA

View Full Version : depth buffer and glVertex2f doubt



ggauravr
05-22-2010, 05:45 PM
If we ve enabled depth test..and glut_depth in display mode..and while drawing say a simple polygon..if we use glvertex2f(x,y)..and suppose we ve defined our viewing vol as glOrtho(x,x1,y,y1,-10,10);
..then where actually in z-axis the polygon is drawn ?? is it in z=0 plane or z=-10 plane coz depth buffer is initialized to farthest value?? ..anyone plz help me get this..

ZbuffeR
05-22-2010, 05:58 PM
When you are not sure, read the docs :
http://www.opengl.org/sdk/docs/man/xhtml/glVertex.xml
It is written black on white "When only x and y are specified, z defaults to 0 and w defaults to 1".
This z is not the same as the depth buffer value, which store a normalized value of the result of the projection. In your case with z=0 and an ortho projection on -10;10 range, it would be 0.5

mhagain
05-22-2010, 05:59 PM
Z is at 0: http://www.opengl.org/sdk/docs/man/xhtml/glVertex.xml


When only x and y are specified, z defaults to 0 and w defaults to 1. When x, y, and z are specified, w defaults to 1.