I have been attempting to create a timer for my game and I heard about QueryPerformanceCounter and QueryPerformanceFrequency. Could someone please explain how these can be used to calculate time/fps/ticks in a game loop?.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Microsoft support has a Knowledge Base article specifically about this:
How To Use QueryPerformanceCounter to Time Code
Basically you use
QueryPerformanceCounterto get a high resolution timer value before and after the event you want to time.Then use
QueryPerformanceFrequencyto get the number of ticks per second. Divide the time difference by this value to convert the value to seconds.