pfuTimer(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages pfuTimer(3pf)NAME
pfuNewTimer, pfuInitTimer, pfuStartTimer, pfuEvalTimers, pfuEvalTimer,
pfuStopTimer, pfuActiveTimer - Benchmarking and interval timing
facilities.
FUNCTION SPECIFICATION
#include <Performer/pfutil.h>
pfuTimer * pfuNewTimer(void *arena, int size);
void pfuInitTimer(pfuTimer *timer, double start, double delta,
void (*func)(pfuTimer*), void *data);
void pfuStartTimer(pfuTimer *timer);
void pfuEvalTimers(void);
int pfuEvalTimer(pfuTimer *timer);
void pfuStopTimer(pfuTimer *timer);
int pfuActiveTimer(pfuTimer *timer);
struct _pfuTimer
{
double tstart, tstop, tdelta;
int frames;
double tnow;
double fraction;
void (*func)(struct _pfuTimer *timer);
void *data;
int dataSize;
};
typedef struct _pfuTimer pfuTimer;
DESCRIPTION
pfuTimers provide a real-time, frame rate independent mechanism for
defining time-based behavior. A pfuTimer is typically initialized with
start and stop times, a callback function, and is triggered with
pfuStartTimer. Then each time pfuEvalTimer is called, the function
callback will be invoked and can then carry out actions based on the
current time.
pfuNewTimer creates a new pfuTimer structure in arena as well as a user-
data memory block of size bytes that is referenced by the data member of
the pfuTimer structure.
Page 1
pfuTimer(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages pfuTimer(3pf)
pfuInitTimer initializes the starting time (tstart), duration (tdelta),
function callback (func), and user data (data) of timer to start, delta,
func and data. User data is copied by value, not by reference.
pfuStartTimer starts timer and adds it to a static list of active timers.
All timers in this list are evaluated by pfuEvalTimers and a single,
activated timer may be evaluated by pfuEvalTimer. A timer must be
evaluated for its function callback to be invoked.
When a timer is evaluated, the current time is checked against its active
interval defined by [tstart, tstop]. If the current time is within this
interval, func will be invoked with a pointer to the pfuTimer. The
following elements of the timer will be set:
frames
The number of times the pfuTimer has been evaluated,
tnow The current time in seconds,
fraction
The fraction of the interval that has passed, (tnow-
tstart)/(tstop-tstart). This ranges from 0 to 1.
data The user-data memory block referenced by the timer.
If the current time is not within the active interval, the timer will be
removed from the internal timer list.
pfuStopTimer stops timer and removes it from the internal timer list.
pfuActiveTimer returns TRUE if timer is active and FALSE otherwise.
NOTES
pfuTimer utilizes pfGetTime and its accuracy is dependent on the
resolution of available system timers. See pfGetTime for more details.
The libpfutil source code, object code and documentation are provided as
unsupported software. Routines are subject to change in future releases.
SEE ALSO
pfGetTime, pfInitClock
Page 2