Skip to main content
gamedev.net
🔒 Locked

Timers

Started by Spartacus 4 replies 400+ views
Original Post
Spartacus
Spartacus
What timer would be appropriate to use for my game? I''ve searched the windows documents for timers and I found some ways to do this. One way to do this is to use the function GetTickCount() but I dont know if the timer resolution is good enough (1/1000 sec). And there''s another function timeGetTime() but what is the difference between timeGetTime() and GetTickCount(). Can someone tell me what the difference is? And last, QueryPerformanceCount and QueryPerformanceFrequency(). This is a timer with a really high resolution but I don''t know if I''ll ever need it. What kind of timer do modern games use today? Thanks, René
Real programmers don't document, if it was hard to write it should be hard to understand
Shannon Barber
Shannon Barber
It''s hard to say what most games use, if I remember correctly timeGetTime is an ansi (or iso, or some org.) standard function that''s good for cross-platform stuff (like it compiles on *everything*, Windows, Mac, QNX, the PS3, your cell phone, etc...
but it''s only good to 1ms.

I use Queryxxxx for the dramtic increase in precision and accuracy (~5us). If that''s not good enough, you can do tricks with the rtdsc op code and time stuff to the cpu clock cycle (~1ns).

Magmai Kai Holmlor
- Not For Rent
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Big Sassy
Big Sassy
I personally made a class for timing with QueryPerformanceCounter(), but that doesn''t mean it''s the right way. I just wanted to use the most accurate timer.
Gillies
Gillies
I did the same as BS. I far as I can tell QueryPer... functions are avaiable on all windows machines since the basic pentium so you should be OK for windows. Cross platform stuff I have no idea about.

The resolution of the Performance counter is very accurate - I think I get about 500K counts per second on my machine.

Stick it in a class and hide the count units from the rest of the code. Then create methods to ask for a time to any accuracy you require.
Null and Void
Null and Void
quote:
Original post by Gillies
Cross platform stuff I have no idea about.


For my current engine I''m using the SDL to handle all of the OS specific stuff. It handles all the time functions as well. In Windows it will use the performance timer automatically if it''s available. It isn''t really a single solution to the cross platform high performance timer, but it works for me .

[Resist Windows XP''s Invasive Production Activation Technology!]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.