PDA

View Full Version : Need to invert Z?



Mikey
09-28-2000, 01:04 AM
Someone PLEASE tell me what I'm doing wrong.
If I set both modelview and projectionmatrixes to Indentity. And then when having matrixmode gl_projection, call glOrtho(1,-1,1,-1, 0, 100) I would assume my Z gets higher farther into the screen, and that I can easily draw polygons with a Z-value of 3, 4 etc. but I cant, I have to negate the z-values so I get -3, -4 etc to get anything to show up on the screen, why? What is that I'm missing?

/Mike

StephenNitro
09-28-2000, 03:10 AM
If you use the command
glTranslatef( 0.0f , 0.0f, -value);

then when you draw the image you won't have to set the z value to anything as this has already been set at the beginning of the scene

Mikey
09-28-2000, 03:25 AM
Well, except for the fact that when I draw a 3d object, I will ofcourse want different z-values for every vertex in the object. Anyway, after reading a bit further on this messageboard, it seems I've missunderstood something, and that OpenGL really does consider negative z values as further into the screen, but that it at some point suddenly flips things, so that a higher z-value means further into the screen, otherwise the glDepthFunc(GL_LESS) would produce rather strange results. I highly disapprove of this incosistency, but if it is the way it is, I suppose I'll have to accept it =)