Newbie GL_DEPTH_TEST Question

I’m playing around with drawing some stuff in 3d. Right now, I’m just drawing 2 triangles, but with GL_DEPTH_TEST enabled I never see anything (just a black screen). If I disable GL_DEPTH_TEST, I see the triangle drawn last (the green one). Any help would be greatly appreciated!

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);  // red triangle
glVertex3f(0.5, 0, -0.25);
glVertex3f(0, .5, -0.25);
glVertex3f(-0.5, 0, -0.25);
glColor3f(0, 1, 0); // green triangle
glVertex3f(-.5, 0, +0.25);
glVertex3f(0, 0.5, +0.25);
glVertex3f(0.5, 0, +0.25);
glEnd();
glDisable(GL_DEPTH_TEST);

Thanks.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.