Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why does glutTimerFunc() only execute my callback once?

callback execute
0
10 Posted

Why does glutTimerFunc() only execute my callback once?

1
10

GLUT’s function for starting a timer and specifying a timer callback, glutTimerFunc(), is specified to execute the callback after the elapsed time, then delete the timer. This is the way timers work in several APIs. Often, repeated callbacks are useful. Implement this by resetting the timer within your callback routine. For example, the following timer callback routine resets the timer for repeated callbacks: static void timerCallback (int value) { /* Do timer processing */ /* maybe glutPostRedisplay(), if necessary */ /* call back again after elapsedUSecs have passed */ glutTimerFunc (elapsedUSecs, timerCallback, value); } 3.030 I need to set up different tasks for left and right mouse button motion. However, I can only set one glutMotionFunc() callback, which doesn’t pass the button as a parameter. You can easily set up different tasks depending on the state of the SHIFT, ALT, and CTRL keys by checking their state with glutGetModifiers().

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123