get current time during runtime...

Started by
16 comments, last by songho 15 years, 4 months ago
not decreasing ....sudden decreasing and then sudden increasing...

and how can it possible that GLUT library has broken....because everything is fine....all simulation works...all the input and feedback function ...

actually i applied this code into "GLUT display function" ....am i doing right...?

and please show me your result...when u checked...

thanks...
Advertisement
Looks kind of like an integer overflow issue, though the cycle point seems odd. What happens if you use a long int or unsigned long int?

Found this while googling, maybe it has something to do with your problem?
Could also be if you have a multicore machine. Without proper drivers/patches QPC will return erroneous data when the program is swapped to a different core.
i checked with long int and unsigned long int.....but just removed decimal numbers...

means the problm is same.....

first some positive numbers...like

23
45
45667743
34567788
23455565

then after

-2344
-2434555
-2344455

then again positive and again negative..like repetition of loop...


if you have a good example picture of output time then please share with me...or show me...i want to check...

coz i couldn't solve this problm...
luckyyyyyy,
Here is a screenshot of the GLUT_ELAPSED_TIME output from my display callback function.


Notice the time resolution of GLUT_ELPASED_TIME. As you can see, the resolution of GLUT timer is around 15 ms. That's why same numbers are duplicated many times and it suddenly jump to the next number.

For applications with fast frame rates, you need a high resolution timer to measure more accurate elapsed time (at least 1ms difference).
The QueryPerformanceCounter function retrieves the current value of the high-resolution performance counter, if one exists.
BOOL QueryPerformanceCounter(

LARGE_INTEGER *lpPerformanceCount // address of current counter value
);
This function returns quantity of steps executed by the processor from the moment of inclusion of the computer.

The QueryPerformanceFrequency function retrieves the frequency of the high-resolution performance counter, if one exists.
BOOL QueryPerformanceFrequency(

LARGE_INTEGER *lpFrequency // address of current frequency
);
This function returns clock frequency of the processor.

Thus, a difference of values received from function QueryPerformanceCounter at the different moments of time, we divide into value from QueryPerformanceFrequency.
Result - time in seconds.
oh much much thanks songho ......

but in my system i can not see like this output......and my output is in negative numbers whyyyy and there is not a fix interval some time it change very much and some time low....i don't know yyy.......i searched google but no result...

what can i do now.........is there any other command to get time interval.....?
Well, please try C standard clock() first. I believe GLUT also uses clock() function internally to measure time, so the result should be same as glutGet(GLUT_ELAPSED_TIME).

Also, QueryPerformanceCounter() is very high resolution timer as sgi1981 mentioned. But, it is a Windows specific API.

Please check the following link . It explains how to use QueryPerformanceCounter() and an example of source code.
High Resolution Timer

This topic is closed to new replies.

Advertisement