PDA

View Full Version : glutTimerfunc



locomo
12-03-2002, 09:13 PM
Hi I have to use glutTimerFunc
in order to simulate day and night
I have a directional light source which shows the day, this light source then should be disabled for the night
kindly suggest

cbwan
12-04-2002, 02:45 AM
supposing your light is GL_LIGHT0 :

glutTimerFunc( 10000, &timerFunc, 0 );
// change every 10seconds

timerFunc( int value ) {
static bool daylight = true;

if( daylight )
glEnable(GL_LIGHT0);
else
glDisable(GL_LIGHT0);

daylight = !daylight;

/* rearm the timer */
glutTimerFunc( 10000, &timerFunc, 0 );
}