Archived

This topic is now archived and is closed to further replies.

duck17

time accuracy

Recommended Posts

My question is with regard to calculating a "delta time" for my frame-rate independent animations. Currently i am using the win32 api function GetCurrentTime() and performing a difference of times to find a delta-T for my animations. My question is, is there a better api function (faster or more accurate) for finding the current time or change in time? Thanks - Duck17

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I use timeGetTime(). I use timeBeginPeriod(1) before I start using timeGetTime to get 1 ms accuracy, which is accurate enough for my needs. And of course timeEndPeriod(1) after my program is finished.

Share this post


Link to post
Share on other sites
i just found something in the win32 platform sdk about High-Resolution Timers, with accuracy up to 1 billionth of a second on a 1ghz cpu.

Anyone used that before or have any comments?

Share this post


Link to post
Share on other sites
I prefer to use QueryPerformanceCounter instead of timeGetTime. Though I usually add a timeGetTime fallback in programs I''m going to distribute. Never know when someone''s going to be using an older computer, and I''m not sure what x86 version that started with...

And there''s also the RTDSC instruction (think that''s what it is... might be misspelled slightly, never used it)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Do you really need that kind of accuracy for a game?

I never understood why people want to use such fine accuracy for a game. 1 ms accuracy is plenty for a game, assuming your game doesn''t run faster than 1000 fps! I know people are concerned about quantization errors, like if your game ran at an average of 100 fps, this may mean one frame took 12 ms and the next took 8 ms, and the next takes 10 ms. Sure each frame is quantized only to the nearest ms of accuracy, but over several frames those tiny little quantization errors will average out.

Share this post


Link to post
Share on other sites
The main reason I use them? To help track down slow code paths. FPS calculations and time scaleing aren''t the only uses for timers, and there''s no reason to have multiple types of timers just because you don''t need as fine of a resolution for some things as you do for others.

Share this post


Link to post
Share on other sites
well i''d prefer better accuracy.. especially if the game is going to be multiplayer ready, i would want to make sure things are as syncronized as possible. there is enough lag already with your average internet connection. Also, i just looked at the directx8 sample source code and they all use QueryPerformanceCounter(), so i think ill go with that. Antyrg''s idea is pretty good too. I just finished reading up on the QueryPerformance functions and it wouldnt be that hard to run a check to see if its supported, and switch to an older less accurate method if needed.
But anyways, thanks for all your suggestions!

Share this post


Link to post
Share on other sites