PDA

View Full Version : timer function



12-05-2001, 09: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???

Thanks.
an opengl idiot =)

bondi
12-06-2001, 02: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
SetTimer(1,4000,NULL)
}

...
case WM_TIMER:
update();
...

void update()
{
//update the screen
}

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

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

hilbert
12-06-2001, 09: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/