Jump to content
  • Advertisement

Archived

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

Armera

DirectX Timing

This topic is 6406 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

Can anyone tell me or point me in a direction to help me understand high performance timers and using timing within programs. All of my programs all deal with input from the keybaord and nothing on timing. I understand d3d and dd very well but i am unable to implement anything because of this. (For example using the gamacontrol to do a fade on the primary surface taking only 4 seconds to go from a picture to black.) Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
use QueryPerformanceFrequency() and QueryPerformanceCounter()
you can also use GetTickCount() but it has a minimum resolution of 55ms on Win9x

Share this post


Link to post
Share on other sites
I understand there are QueryPerformance functions to do this but i dont understand timing in general at all. I know it seems weird to know 3D programming without knowing anything about timers.

Share this post


Link to post
Share on other sites
What exactly are you looking for? I think I might be able to help, but your question is a bit vague. Have you ever used a timer before? Are you just looking for ways to use timers?

Kevin =)

Share this post


Link to post
Share on other sites
This is one of those things that looks complicated, but isn't-

You use QueryPerformanceFrequency() to get the frequency, ie how many ticks per second, then whenevr you want to time somthing you call QueryPerformanceCounter() - this returns you the tick count. Note that these return some weird structures - look them up in the microsoft sdk, and you will find they are just int64's.

Anyway, an example, if you want to time how long a proccess took, in seconds, do the following-

LARGE_INTEGER StartTime; QueryPerformanceCounter(&StartTime);

// Do whatever here;

LARGE_INTEGER EndTime; QueryPerformanceCounter(&EndTime);
LARGE_INTEGER Freq; QueryPerformanceFrequency(&Freq);

double TimeTaken = (EndTime.QuadPart-StartTime.QuadPart)/(double)Freq.QuadPart;



You would probably want to avoid the above code in a game - that calculation as a slow as hell, but it shows the teqneque.
-Lethe



Edited by - Lethe on November 29, 2000 8:37:32 AM

Share this post


Link to post
Share on other sites
Lethe:
Thanks! That helped me a little on understanding them. Would there be any place to maybe find some tutorials on this subject?

grasshopa55:
Yea i used windows WM_TIMER before but i heard it is unreliable for timing programs. Thats why i want to learn about high performance timers.

Share this post


Link to post
Share on other sites
go to Witchlords site www.witchlord.com and download his first tutorial, he has a timer class which is exactly what you are looking for and you can just plug it into your programs

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!