Currently, OpenGL has whichever part of the polygon drawn last, is on top.
So in 3D, if I rotate this object so the part that was drawn last should be behind the part that was drawn first, the former still shows up on top of the latter.
Is there any easy way to fix this so it always draws the part closer to the screen on top of the part farther from it when two parts overlap?
Here's what I'm currently using to draw this shape:
Code:
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef (xtheta, 1.0f, 0.0f, 0.0f);
glRotatef (ytheta, 0.0f, 1.0f, 0.0f);
glRotatef (ztheta, 0.0f, 0.0f, 1.0f);
glBegin(GL_POLYGON);
glColor3f (0.0f, 0.0f, 1.0f); glVertex3d(0, 0, 0);
glColor3f (0.0f, 0.5f, 1.0f);glVertex3d(.75, 0, 0);
glColor3f (0.0f, 1.0f, 0.5f);glVertex3d(0, .8, 0);
glColor3f (0.0f, 1.0f, 0.0f); glVertex3d(0, 0, 1);
glEnd();
glPopMatrix();
Any help is appreciated.