timer with light

How can I use the glutTimerFunc() to show a day cycle…that is have the light enabled when drawn…and then after some time disable the light automatically to exhibit night, and repeat in this fashion?

Thanks for your help.

ALso can some one explain the timer functin
void glutTimerFunc(unsigned int msecs,
void (*func)(int value), value);

I dont understand whats the value parameter. The documnetation on the site does not help much.
Thanks again,

The msecs is time to wait before calling the routine in milli-seconds. 1000 milli seconds in a second.

func is function to call when time run’s out.

value could be used to tell what function called it.

glutTimerFunc( 100, my_timer, 1); // call my_timer after 100 milli seconds has past.

void my_timer( int te )
{
// Note this will only be called once unless the timer is reset with another call to glutTimerFunc.

glutTimerFunc( 100, my_timer, 1); // Reset timer to 100 ms, note having at the of routine will make it call itself every 100 ms.

}

Now we could add something like:

te++;
if( te < 10 ) glutTimerFunc( 100, my_timer, te); // now it will only call its self 10 times.

Hope this helps

Originally posted by lara:
[b]ALso can some one explain the timer functin
void glutTimerFunc(unsigned int msecs,
void (*func)(int value), value);

I dont understand whats the value parameter. The documnetation on the site does not help much.
Thanks again,[/b]