Problems with depth

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.

Have you enabled Depth testing?

glEnable(GL_DEPTH_TEST);

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.

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.