glut/progs/examples/movelight.c
/*  Here is where the light position is reset after the modeling
 *  transformation (glRotated) is called.  This places the 
 *  light at a new position in world coordinates.  The cube
 *  represents the position of the light.
 */
Here is where the light position is reset after the modeling
transformation (glRotated) is called.  This places the
light at a new position in world coordinates.  The cube
represents the position of the light.
Here is where the light position is reset after the modeling transformation ( glRotated ) is called . This places the light at a new position in world coordinates . The cube represents the position of the light .
void
display(void)
{
  GLfloat position[] =
  {0.0, 0.0, 1.5, 1.0};
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glTranslatef(0.0, 0.0, -5.0);
  glPushMatrix();
  glRotated((GLdouble) spin, 0.0, 1.0, 0.0);
  glRotated(0.0, 1.0, 0.0, 0.0);
  glLightfv(GL_LIGHT0, GL_POSITION, position);
  glTranslated(0.0, 0.0, 1.5);
  glDisable(GL_LIGHTING);
  glColor3f(0.0, 1.0, 1.0);
  glutWireCube(0.1);
  glEnable(GL_LIGHTING);
  glPopMatrix();
  switch (obj) {
  case TORUS:
    glutSolidTorus(0.275, 0.85, 20, 20);
    break;
  case TEAPOT:
    glutSolidTeapot(1.0);
    break;
  case DOD:
    glPushMatrix();
    glScalef(.5, .5, .5);
    glutSolidDodecahedron();
    glPopMatrix();
    break;
  case TET:
    glutSolidTetrahedron();
    break;
  case ISO:
    glutSolidIcosahedron();
    break;
  }
  glPopMatrix();
  glPushAttrib(GL_ENABLE_BIT);
  glDisable(GL_DEPTH_TEST);
  glDisable(GL_LIGHTING);
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  gluOrtho2D(0, 3000, 0, 3000);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  output(80, 2800, "Welcome to movelight.");
  output(80, 2650, "Right mouse button for menu.");
  output(80, 400, "Hold down the left mouse button");
  output(80, 250, "and move the mouse horizontally");
  output(80, 100, "to change the light position.");
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();
  glPopAttrib();
  glutSwapBuffers();
}
void display ( void ) { GLfloat position [ ] = { 0.0 , 0.0 , 1.5 , 1.0 } ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; glMatrixMode ( GL_MODELVIEW ) ; glPushMatrix ( ) ; glTranslatef ( 0.0 , 0.0 , -5.0 ) ; glPushMatrix ( ) ; glRotated ( ( GLdouble ) spin , 0.0 , 1.0 , 0.0 ) ; glRotated ( 0.0 , 1.0 , 0.0 , 0.0 ) ; glLightfv ( GL_LIGHT0 , GL_POSITION , position ) ; glTranslated ( 0.0 , 0.0 , 1.5 ) ; glDisable ( GL_LIGHTING ) ; glColor3f ( 0.0 , 1.0 , 1.0 ) ; glutWireCube ( 0.1 ) ; glEnable ( GL_LIGHTING ) ; glPopMatrix ( ) ; switch ( obj ) { case TORUS : glutSolidTorus ( 0.275 , 0.85 , 20 , 20 ) ; break ; case TEAPOT : glutSolidTeapot ( 1.0 ) ; break ; case DOD : glPushMatrix ( ) ; glScalef ( .5 , .5 , .5 ) ; glutSolidDodecahedron ( ) ; glPopMatrix ( ) ; break ; case TET : glutSolidTetrahedron ( ) ; break ; case ISO : glutSolidIcosahedron ( ) ; break ; } glPopMatrix ( ) ; glPushAttrib ( GL_ENABLE_BIT ) ; glDisable ( GL_DEPTH_TEST ) ; glDisable ( GL_LIGHTING ) ; glMatrixMode ( GL_PROJECTION ) ; glPushMatrix ( ) ; glLoadIdentity ( ) ; gluOrtho2D ( 0 , 3000 , 0 , 3000 ) ; glMatrixMode ( GL_MODELVIEW ) ; glPushMatrix ( ) ; glLoadIdentity ( ) ; output ( 80 , 2800 , " " ) ; output ( 80 , 2650 , " " ) ; output ( 80 , 400 , " " ) ; output ( 80 , 250 , " " ) ; output ( 80 , 100 , " " ) ; glPopMatrix ( ) ; glMatrixMode ( GL_PROJECTION ) ; glPopMatrix ( ) ; glPopAttrib ( ) ; glutSwapBuffers ( ) ; }
Here is where the light position is reset after the modeling
  transformation (glRotated) is called.
Here is where the light position is reset after the modeling transformation ( glRotated ) is called .