View Full Version : timer function

12-05-2001, 08:42 PM
Does anyone have any examples/ idea how to implement an openGL timer function???
For example I would like the program to call a function redraw every 4 secs.

I read about the function glutTimerFunc. But still unsure how to use it. Will some kind soul help???

an opengl idiot =)

12-06-2001, 01:17 AM
you can use Windows timer function.
Use SetTimer(ID,time intervall in ms, NULL);
to set up the timer.
and make a message handler for WM_TIMER

for example;

void Init()
//windows sends WM_TIMER every 4 sec

case WM_TIMER:

void update()
//update the screen

12-06-2001, 04:35 PM
Thanks bondi,

However, I am working in an unix environment,
so cannot use the windows functions.
Thanks anyway =)

12-06-2001, 08:35 PM
Try to #include <unistd.h>//unix standard
than call the function usleep( int sec )
where sec is micro second. type info usleep for more information!!
Try my masterpiece http://sourceforge.net/projects/mathdev/