title: openGL spotlight troubles
body: <p>Ok so I'm trying to emulate the behaviour of a flashlight. For the time being I'm just trying to get a spotlight to show up on a sphere. Now the code below works, but it only works when the <code>GL_SPOT_CUTOFF</code> is set to 180 which creates a uniform distribution of light - not what I'm going for. If I try to set it to any other value then it just stops working. Here is the code</p>
  
  <pre><code>GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
  GLfloat light_pos [4] = {5, 2, -10, 1.0};
  
  glLightfv (GL_LIGHT0, GL_SPECULAR, mat_specular);
  glLightfv (GL_LIGHT0, GL_POSITION, light_pos);
  
  glLightf (GL_LIGHT0, GL_SPOT_CUTOFF, 20.0f);
  glLightf (GL_LIGHT0, GL_SPOT_EXPONENT, 100.0);
  
  GLfloat spotDir [] = {0.0, 0.0, 0.0};
  glLightfv (GL_LIGHT0, GL_SPOT_DIRECTION, spotDir);
  
  glutSolidSphere (2, 20, 20);
  
  glFlush ();
  glutSwapBuffers ();
  </code></pre>
  
  <p>I've enabled lighting and have done all the initialization stuff. All the surface normals are calculated from glutSolidSphere so don't know what else could be failing...any ideas?</p>