Im having an issue using glutTimerFunc to register a callback. Apparently it takes three arguments, two ints and a pointer to the callback function. I dont get how to use this and the glut spec pdf doesnt give much help either. Anybody?
09-21-2002, 01:28 PM
This is the description listed in the GLUT 3 manual I downloaded the other week from the GLUT site. To cut the description short the values are as follows:
param1 - number of milliseconds for each call
param2 - the name of the function
param3 - the identity of the timer to use
So we can have for example 4 separate timers running at once, with 2 for example running within the same time frame :
void timer1(int value);
void timer2(int value);
void timer3(int value);
EDIT: forgot to add example function code...
void timer1(int value)
//no need to test for value as this is
//only used by a single timer
//we could use this for incrementing the
//rotation of an object
void timer3(int value)
//Because this timer is used by 2
//different timer values we need to check
//which one it is and work on them
if (value == 3) yrot++;
if (value == 4) zrot++;
So, timer1 will execute every 10 milliseconds, timer2 every 20 milliseconds and timer3 every 30 milliseconds. Each to carry out different tasks.
I hope that helps you
GLUT Description of Timer Callback Function
glutTimerFunc registers a timer callback to be triggered in a specified number of milliseconds.
void glutTimerFunc(unsigned int msecs,
void (*func)(int value), value);
msecs Number of milliseconds to pass before calling the callback.
func The timer callback function.
value Integer value to pass to the timer callback.
glutTimerFunc registers the timer callback func to be triggered in at least msecs milliseconds. The
value parameter to the timer callback will be the value of the value parameter to glutTimerFunc. Multiple
timer callbacks at same or differing times may be registered simultaneously.
The number of milliseconds is a lower bound on the time before the callback is generated. GLUT attempts
to deliver the timer callback as soon as possible after the expiration of the callback’s time interval.
There is no support for canceling a registered callback. Instead, ignore a callback based on its value parameter
when it is triggered.
[This message has been edited by tinak (edited 09-21-2002).]
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.