Jump to content
  • Advertisement
Sign in to follow this  
pressgreen

glutTimerFunc question

This topic is 2106 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does the glutTimerFunction work on a thread separate from the main thread when it is executed? Used to call the function that encapsulates it, when it calls that parent function it does not immediately get placed in a stack. I mean the line proceeding glutTimerFunc is then executed before the next call to the parent function is executed. I thought in a recursive function the line proceeding the call to the function is not executed until the base case is satisfied. Why is this or how is this working in the background? What is the voodoo behind the glutTimerFunction? 

Edited by greenzone

Share this post


Link to post
Share on other sites
Advertisement

There's nothing spectacular about it. It starts a timer, and when the timer expires, GLUT event loop issues a call to the timer callback. No additional threads are needed or used. It probably uses OS-specific timer events, and when the OS notifies GLUT that the timer has expired, GLUT responds by calling your callback.

Edited by Brother Bob

Share this post


Link to post
Share on other sites

When you say "GLUT even loop issues a call to the timer callback", do you mean the GLUT event loop calls the parent function that encapsulates the glutTimerFunction?

Share this post


Link to post
Share on other sites

It's not very clear what you mean by parent function. When you call glutTimerFunc() you pass it a function pointer. When the GLUT main loop notices the requested amount of time has passed it calls that function pointer.

Share this post


Link to post
Share on other sites

Brother Bobs edit makes more sense to me now. My callback function that I place the glutTimerFunc is what I was thinking when I was saying parent function. Thanks that makes a lot of sense.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!