Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: glutTimerFunc()

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2003
    Posts
    6

    glutTimerFunc()

    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

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: glutTimerFunc()

    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

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Jan 2003
    Location
    Virginia
    Posts
    601

    Re: glutTimerFunc()

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •