View Full Version : How to setup timer in GLUT

01-03-2002, 09:39 PM
Hi everyone,

I want to setup a timer in my program. This program will display the time using the timer.
What my problem is I don't know how to setup the timer.
I've look out in many book and found nothing.

Recently someone post a same topic about this timer in this forum.
One of the guy that reply insisted of using QueryPerformanceFrequency to get the frequency of the timer
and QueryPerformanceCounter to get the value of the timer.

I'm beginner programmer and don't know how to do it. Can someone explain a little bit more
maybe with some coding. Is there any other way to setup this timer?

01-06-2002, 11:44 PM
Well, wait a minute. QueryPerformanceCounter is a very precise counter. It's used, for example, for smoothest animations at around 100fps (where a granularity of 1ms becomes noticeable) and it's also necessary if you want to display, at each frame, the number of fps. But if all you want is a timer that "ticks" once per second, or even once per millisecond, you should use glutTimerFunc : that's much easier ! Look in the GLUT documentation, it explains perfectly how to use it.

P.S. : In a program that displays the time at each frame, I can't see why you need a timer. All what you need is a function that returns the time of day. There is such a function in the standard C API, why don't you use it ?