Background object is drawn in front of foreground object in OpenGL?
For testing purposes let's assume I've draw 2 teapots with glutSolidTeapot() , like this: glColor3f(1.0f, 0.0f, 0.0f); // Red teapot glutWireTeapot(1.0f); glColor3f(0.0f, 1.0f, 0.0f); // Green teapot glTranslatef(0.0f, 0.0f, 3.0f); glutWireTeapot(1.0f); The camera is initially located at (x,y,z) = (0.0f, 0.0f, 5.0f) and I'm looking at z = -1 (this is camera position #1). I'm sure you understand that the green teapot is the closest object to the camera and the red one is behind it. The problem is that the red one is drawn like it's in front of the green one, which doesn't look right: Example: