PDA

View Full Version : glutTimerFunc()



GlutNewbie
02-28-2003, 05:59 PM
Hi.

I'm a little confused about how glutTimerFunc() is supposed to work. Here's what I want to do.

1. I want to find out if the user took less than 10 milliseconds to click the left mouse button.

2. If yes, then I will end the animation.

3. If no, then the animation will continue.

glutTimer(aNumber, aFunc, aValue);

4. This is what someone told me about glutTimerFunc()....glutTimerFunc will call aFunc after aNumber time has passed but not if the user clicks the left mouse button before aNumber is up. This seems a little odd to me but I took her word for it because she knows more than I do. However, that isn't working for me. Can anyone tell me what needs to be done?

Thanks

nexusone
02-28-2003, 07:30 PM
glutTimerFunc is a count down timer, after set time has elapsed, the target routine is called.
It may not work the way you want, let's say your rendering function takes 100 ms to draw the screen, your 10ms timer would not be called until 100 ms since glut will wait until rendering is done before calling it.

So the timer is not absolute time past when called and is not effected by a mouse click.


glutTimerFunc( 100(time in milli seconds ,My_timer_routine, 1 )

void My_timer_routine( void )
{
// Do something after X time has past

}



Originally posted by GlutNewbie:
Hi.

I'm a little confused about how glutTimerFunc() is supposed to work. Here's what I want to do.

1. I want to find out if the user took less than 10 milliseconds to click the left mouse button.

2. If yes, then I will end the animation.

3. If no, then the animation will continue.

glutTimer(aNumber, aFunc, aValue);

4. This is what someone told me about glutTimerFunc()....glutTimerFunc will call aFunc after aNumber time has passed but not if the user clicks the left mouse button before aNumber is up. This seems a little odd to me but I took her word for it because she knows more than I do. However, that isn't working for me. Can anyone tell me what needs to be done?

Thanks

shinpaughp
02-28-2003, 09:04 PM
You probably want to use glutMouseFunc, but use a system timer depending on your platform, not to call a function but to determine the time difference between the start time and the time left mouse button is pressed.

Then, in your mousefunc if time diff < interval then stop animation else continue animation and reset start time to current time.