title: Lighting not working on OpenGL - Solid color
body: <p>The lighting doesn't work, the object appears with solid color. The color itself changes with the material or lighting parameters but no shadow or anything just solid grey.</p>
  
  <p>Here's part of the code:</p>
  
  <pre><code>glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glFrontFace(GL_CCW);
  glShadeModel(GL_FLAT);
  glEnable(GL_LIGHTING);
  
  GLfloat amb[] = {0.6, 0.6, 0.6, 1.0};
  GLfloat dif[] = {0.8, 0.8, 0.8, 1.0};
  GLfloat spec[] = {0.5, 0.5, 0.5, 1.0};
  GLfloat pos[] = {0.0, 0.0, 30.0};
  
  glEnable(GL_LIGHT0);    
  
  glLightfv(GL_LIGHT0, GL_AMBIENT, amb);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, dif);
  glLightfv(GL_LIGHT0, GL_SPECULAR, spec);
  glLightfv(GL_LIGHT0, GL_POSITION, pos);
  
  
  GLfloat co[4]={0.5, 0.5, 0.5, 0.5};
  GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat mat_shininess[] = { 1.0 }; 
  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, co);
  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
  
  for(int i=0; i &lt; numofTr; i++)
  {       
  glBegin(GL_TRIANGLES);
    glNormal3f(tr[i].v1-&gt;n.x, tr[i].v1-&gt;n.y, tr[i].v1-&gt;n.z);
    glVertex3f(tr[i].v1-&gt;x, tr[i].v1-&gt;y, tr[i].v1-&gt;z);    
    glNormal3f(tr[i].v2-&gt;n.x, tr[i].v2-&gt;n.y, tr[i].v2-&gt;n.z);
    glVertex3f(tr[i].v2-&gt;x, tr[i].v2-&gt;y, tr[i].v2-&gt;z);    
    glNormal3f(tr[i].v3-&gt;n.x, tr[i].v3-&gt;n.y, tr[i].v3-&gt;n.z);
    glVertex3f(tr[i].v3-&gt;x, tr[i].v3-&gt;y, tr[i].v3-&gt;z);    
  glEnd();
  }
  </code></pre>
  
  <p>I don't know what I'm missing, the normals look good when displayed along with the object.</p>