Jump to content
  • Advertisement
Sign in to follow this  
dejangex

Microsecond accuracy timer for C# but not for C++?

This topic is 4449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Reading the book "Beginning C# Game Programming" I found something very interesting. I have searched the google and this forum but could not find anything about it.
Quote:
Almost all games are time-based. Rare is the game that doesn’t require some use of a timer device. Unfortunately for game programmers, .NET wasn’t really designed with us in mind. The .NET framework was designed with application programmers in mind, so all it includes is a timer system that isn’t very accurate. When is the last time you saw a regular word-processing application require a millisecond-accuracy timer, anyway? Luckily for you and me, the DirectX team at Microsoft decided to fix this problem and gave us a handy, high-precision timer, with time accuracy that no sane game programmer would ever need.We’re talking about microsecond accuracy here. I’m happy with just milliseconds, though. ... Microsoft provided a file called DXUtil.cs that contains this timer, but it’s kind of hidden away in the SDK.You can find it if you go into the Samples\C#\Common directory inside wherever you installed the DirectX 9 SDK. Here’s an example of how to use the timer: float time = DXUtil.Timer( DirectXTimer.GetAbsoluteTime );
How come theres nothing about this on the web? If thay made it for the C# .NET maybe theres one for C++?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
http://support.microsoft.com/kb/q172338/

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
wrong link that was vb
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/timers/timerreference/timerfunctions/queryperformancecounter.asp?frame=true

Share this post


Link to post
Share on other sites
Quote:
Original post by dejangex
QueryPerformanceCounter is really microsecond accurate?

It is debatable, but it is generally accepted to be accurate to ~1 us. Note that a common misconception with timers is that just because they may be precise (ie the give results in very small units), they may not be accurate anywhere near that precision level.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!