PDA

View Full Version : Problems with depth



shellyk
11-25-2002, 07:03 AM
I'm trying to write code for a room with shapes where you can "walk" around the room and look at the shapes from different angles. I'm having a (probably simple) problem that I've been pulling my hair out over:
When I draw say a sphere and a back wall. Regardless of the z-coordinates, whichever I code second comes out in front. Does anyone know what I could be do wrong? Thanks in advance.

nexusone
11-25-2002, 07:45 AM
Have you enabled Depth testing?

glEnable(GL_DEPTH_TEST);

http://www.opengl.org/discussion_boards/ubb/smile.gif


Originally posted by shellyk:
I'm trying to write code for a room with shapes where you can "walk" around the room and look at the shapes from different angles. I'm having a (probably simple) problem that I've been pulling my hair out over:
When I draw say a sphere and a back wall. Regardless of the z-coordinates, whichever I code second comes out in front. Does anyone know what I could be do wrong? Thanks in advance.

Deiussum
11-25-2002, 09:57 AM
Also make sure you actually have a depth buffer. There usually is one by default in Windows, but I noticed that Linux doesn't seem to. If you are using glut and don't use GLUT_DEPTH as one of the bits for glutInitWindowMode(), you don't get a depth buffer.