   light problems
  I'm trying set up the lights in my scene, but everything in becomes grey.. it looks like its some kind of shading, but theres no colors.. #include <math.h>#include <GL/glut.h>#include <stdio.h>#include <stdlib.h>#define PI 3.1415926535897932384626433832795int light_view = 0;void init(void){    GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0};    GLfloat mat_shininess[] = {50.0};    GLfloat light_pos[] = {0.0, 0.0, 4.0, 0.0};    GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0};    glLightfv(GL_LIGHT0, GL_POSITION, light_pos);    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);    glEnable(GL_LIGHT0);    glEnable(GL_LIGHTING);    glClearColor (0.0, 0.0, 0.0, 0.0);    glEnable(GL_DEPTH_TEST);}void CalcNormal(float p1[3], float p2[3], float p3[3], float n[3]){    float v1[3], v2[3], length;    const int x = 0;    const int y = 1;    const int z = 2;    // calculate two vectors from given vertices    v1[x] = p2[x] - p1[x];    v1[y] = p2[y] - p1[y];    v1[z] = p2[z] - p1[z];    v2[x] = p3[x] - p1[x];    v2[y] = p3[y] - p1[y];    v2[z] = p3[z] - p1[z];    // calculate cross product of v1 & v2 to get normal    n[0] = v1[y]*v2[z] - v2[y]*v1[z];    n[1] = v1[z]*v2[x] - v2[z]*v1[x];    n[2] = v1[x]*v2[y] - v2[x]*v1[y];    // calculate length of vector    length = (float)sqrt (n[x]*n[x] + n[y]*n[y] + n[z]*n[z]);    // make sure vector is not too close to zero!    if (length == 0.0f)   length = 1.0f;    // normalise vector by dividing by length    n[x] /= length;    n[y] /= length;    n[z] /= length;}void changeView(GLdouble *a){    glMatrixMode(GL_MODELVIEW);    glLoadIdentity();    gluLookAt(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);    glutPostRedisplay();}void display(void){    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    glPushMatrix();   //bottom of the container   glColor3f(0.0,1.0,0.0);   glBegin(GL_POLYGON);  float n[3];  float p1[] = {-1.0, -1.0, 1.0};  float p2[] = {-1.5, -1.0, 0.0};  float p3[] = {-1.0, -1.0, -1.0};  CalcNormal(p1, p2, p3, n);  glNormal3fv(n);  glVertex3f(-1.0, -1.0, 1.0);  glVertex3f(-1.5, -1.0, 0.0);  glVertex3f(-1.0, -1.0, -1.0);  glVertex3f(1.0, -1.0, -1.0);  glVertex3f(1.5, -1.0, 0.0);  glVertex3f(1.0, -1.0, 1.0);   glEnd();   glColor3f(1.0,0.0,0.0);   glBegin(GL_POLYGON);  p1[0] = 1.0; p1[1] = 1.0; p1[2] = 1.0;  p2[0] = 1.0; p2[1] = -1.0; p2[2] = 1.0;  p3[0] = 1.5; p3[1] = -1.0; p3[2] = 0.0;  CalcNormal(p1, p2, p3, n);  glNormal3fv(n);  glVertex3f(1.0, 1.0, 1.0);  glVertex3f(1.0, -1.0, 1.0);  glVertex3f(1.5, -1.0, 0.0);  glVertex3f(1.5, 1.0, 0.0);   glEnd();   glBegin(GL_POLYGON);  p1[0] = -1.0; p1[1] = 1.0; p1[2] = 1.0;  p2[0] = -1.0; p2[1] = -1.0; p2[2] = 1.0;  p3[0] = 1.0; p3[1] = 1.0; p3[2] = 1.0;  CalcNormal(p1, p2, p3, n);  glNormal3fv(n);  glVertex3f(-1.0, 1.0, 1.0);  glVertex3f(-1.0, -1.0, 1.0);  glVertex3f(1.0, -1.0, 1.0);  glVertex3f(1.0, 1.0, 1.0);   glEnd();   glBegin(GL_POLYGON);  p1[0] = -1.5; p1[1] = 1.0; p1[2] = 0.0;  p2[0] = -1.5; p2[1] = -1.0; p2[2] = 0.0;  p3[0] = 1.0; p3[1] = -1.0; p3[2] = 1.0;  CalcNormal(p1, p2, p3, n);  glNormal3fv(n);  glVertex3f(-1.5, 1.0, 0.0);  glVertex3f(-1.5, -1.0, 0.0);  glVertex3f(-1.0, -1.0, 1.0);  glVertex3f(-1.0, 1.0, 1.0);   glEnd();   glColor3f(0.0,0.0,1.0);   glBegin(GL_POLYGON);  p1[0] = -1.0; p1[1] = 1.0; p1[2] = -1.0;  p2[0] = -1.0; p2[1] = -1.0; p2[2] = -1.0;  p3[0] = -1.5; p3[1] = -1.0; p3[2] = 0.0;  CalcNormal(p1, p2, p3, n);  glNormal3fv(n);  glVertex3f(-1.0, 1.0, -1.0);  glVertex3f(-1.0, -1.0, -1.0);  glVertex3f(-1.5, -1.0, 0.0);  glVertex3f(-1.5, 1.0, 0.0);   glEnd();   glBegin(GL_POLYGON);  p1[0] = 1.0; p1[1] = 1.0; p1[2] = -1.0;  p2[0] = 1.0; p2[1] = -1.0; p2[2] = -1.0;  p3[0] = -1.0; p3[1] = -1.0; p3[2] = -1.0;  CalcNormal(p1, p2, p3, n);  glNormal3fv(n);  glVertex3f(1.0, 1.0, -1.0);  glVertex3f(1.0, -1.0, -1.0);  glVertex3f(-1.0, -1.0, -1.0);  glVertex3f(-1.0, 1.0, -1.0);   glEnd();   glBegin(GL_POLYGON);  p1[0] = 1.5; p1[1] = 1.0; p1[2] = 0.0;  p2[0] = 1.5; p2[1] = -1.0; p2[2] = 0.0;  p3[0] = 1.0; p3[1] = -1.0; p3[2] = -1.0;  CalcNormal(p1, p2, p3, n);  glNormal3fv(n);  glVertex3f(1.5, 1.0, 0.0);  glVertex3f(1.5, -1.0, 0.0);  glVertex3f(1.0, -1.0, -1.0);  glVertex3f(1.0, 1.0, -1.0);   glEnd();    glPopMatrix();    glutSwapBuffers();    glFlush();}void reshape (int w, int h){    glViewport (0, 0, (GLsizei) w, (GLsizei) h);    glMatrixMode (GL_PROJECTION);    glLoadIdentity ();    gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);    GLdouble viewCoordinates[9] = {0.0, 0.0, 8.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0};    changeView(viewCoordinates);}void keyboard (unsigned char key, int x, int y){    switch (key) {   case 'v':   case 'V':  light_view = 0;  break;   case 'l':   case 'L':  light_view = 1;  break;   case 'c':   case 'C':  break;   case 'f':   case 'F':  if (light_view == 0)  { GLdouble viewCoordinates[9] = {0.0, 0.0, 8.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}; changeView(viewCoordinates);  }  break;   case 'r':   case 'R':  if (light_view == 0)  { GLdouble viewCoordinates[9] = {0.0, 0.0, -8.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}; changeView(viewCoordinates);  }  break;   case 't':   case 'T':  if (light_view == 0)  { GLdouble viewCoordinates[9] = {0.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0}; changeView(viewCoordinates);  }  break;   case 'b':   case 'B':  if (light_view == 0)  { GLdouble viewCoordinates[9] = {0.0, -8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}; changeView(viewCoordinates);  }  break;   case 'p':   case 'P':  if (light_view == 0)  { GLdouble viewCoordinates[9] = {-8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}; changeView(viewCoordinates);  }  break;   case 's':   case 'S':  if (light_view == 0)  { GLdouble viewCoordinates[9] = {8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}; changeView(viewCoordinates);  }  break;   case 'a':   case 'A':  if (light_view == 0)  { GLdouble viewCoordinates[9] = {-1.0, 6.0, 4.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}; changeView(viewCoordinates);  }  break;   case 27:  exit(0);  break;   default:  break;    }}int main(int argc, char** argv){   glutInit(&argc, argv);   glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);   glutInitWindowSize (500, 500);   glutInitWindowPosition (500, 500);   glutCreateWindow (argv[0]);   init ();   glutDisplayFunc(display);   glutReshapeFunc(reshape);   glutKeyboardFunc(keyboard);   glutMainLoop();   return 0;}
  You never set the diffuse material of the object you draw, only the specular color and shininess, and so are left with the default material, which is white. White material, white light; there's nowhere you can get a shade of color from. Set the diffuse material to whatever color you want the object to have.   ;  Add something like this to your init fuction :GLfloat dif[] = {1.0f,0.0f,0.0f,1.0f};glLightfv(GL_LIGHT0,GL_DIFFUSE,dif);