I'm trying to figure out how to write my own primitives like gluSolidCube()..
In the following code I'm drawing 2 quads. One with the help of this method (the red one) and another one - by my own with the help of glBegin()/glEnd() (the blue one).
glPushMatrix();
glRotatef(-angleX, 0, 0, 1);
glRotatef(angleY, 0, 1, 0);
glColor3f(1, 0, 0);
glTranslatef(0.6, 0, 0);
glutSolidCube(1);
glColor3f(0, 0, 1);
glTranslatef(-1.2, 0, 0);
glPolygonMode(GL_FRONT, GL_FILL);
glShadeModel(GL_SMOOTH);
glBegin(GL_QUADS);
glVertex3f(0.5, 0.5, 0.5);
glVertex3f(0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, 0.5);
glVertex3f(0.5, 0.5, 0.5);
glVertex3f(0.5, 0.5, -0.5);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(-0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, 0.5);
glVertex3f(-0.5, -0.5, 0.5);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(0.5, 0.5, -0.5);
glVertex3f(-0.5, 0.5, -0.5);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(0.5, 0.5, 0.5);
glVertex3f(-0.5, 0.5, 0.5);
glVertex3f(-0.5, -0.5, 0.5);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(-0.5, -0.5, 0.5);
glEnd();
glPopMatrix();
So as you can see at the following screenshots the lightnings on the red quad is correct unlike the blue one. How to solve this?