Ok, here is part of my source for creating my first 3D application:
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(1.0, 0.0, 0.0); //red
glVertex3f(-6.0, -6.0, 6.0); //left
glColor3f(0.0, 1.0, 0.0); //green
glVertex3f(6.0, -6.0, 6.0); //right
glColor3f(0.0, 0.0, 1.0); //blue
glVertex3f(0.0, 6.0, 0.0); //top
glColor3f(0.0, 1.0, 0.0); //green
glVertex3f(-6.0, -6.0, -6.0);
glColor3f(1.0, 0.0, 0.0); //red
glVertex3f(6.0, -6.0, -6.0);
glColor3f(0.0, 0.0, 1.0); //blue
glVertex3f(0.0, 6.0, 0.0);
glColor3f(1.0, 0.0, 0.0); //red
glVertex3f(-6.0, -6.0, 6.0);
glColor3f(0.0, 1.0, 0.0); //green
glVertex3f(-6.0, -6.0, -6.0);
glColor3f(0.0, 0.0, 1.0); //blue
glVertex3f(0.0, 6.0, 0.0);
glColor3f(0.0, 1.0, 0.0); //green
glVertex3f(6.0, -6.0, 6.0); //left
glColor3f(1.0, 0.0, 0.0); //red
glVertex3f(6.0, -6.0, -6.0); //right
glColor3f(0.0, 0.0, 1.0); //blue
glVertex3f(0.0, 6.0, 0.0); //top
glEnd();
glBegin(GL_QUADS);
glVertex3f(-6.0, -6.0, -6.0);
glVertex3f(-6.0, -6.0, 6.0);
glVertex3f(6.0, -6.0, 6.0);
glVertex3f(6.0, -6.0, -6.0);
glEnd();
glutSwapBuffers();
}
Why does color of the last polygon always override the color even it is at the back.
Please point out what mistakes I have made, thanks!
[This message has been edited by EeeK (edited 07-19-2000).]