negative Z values

Hello!

I’ve been making a 3-D render (from the scratch), and I’ve been having some trouble showing face with some negative-Z vetices.

for example, when you are in a room, the walls start behind you, but you can see then in your front.

with the standard projection formula (x/z , y/z), I get those vertices put in weird places.

Can someone help me?!

Thanks!

Apart from the projection from object space to screen space coordinates, you also have to set a near and far clipping plane for the vertices.

This is exactly what glFrustum does.

http://www.mevis.de/~uwe/opengl/glFrustum.html

Greetz,

Nico