function be made more efficient?

Started by
12 comments, last by JoeCooper 14 years, 3 months ago
There's a lot of ways to calculate framerate. The easiest is probably to use GetTickCount() if you're on windows, (SDL has a similar method that essentially wraps this, I just don't remember its name off the top of my head). Regardless of what API you use to access this functionality what it essentially does is give you the number of milliseconds that have passed since some arbitrary point in time long ago (since the computer was first started I THINK). Now this number is very large, but if you take the difference between two calls to the function you can get how many milliseconds elapsed between them, you can call this your frame time.

long frame_start_time = GetTickCount();//do all your updating / rendering herelong frame_time = GetTickCount() - frame_start_time;/*you can check this value against whatever millisecond latency you want, or you can calculate an actual framerate from it knowing 1000 milliseconds = 1 second... */double frame_rate = frame_time / 1000.0;
Advertisement
thanks you guys, now i seem to have solve that problem but now i want to make sure by testing on other pc's, but am getting mvscrc100.dll missing.
Quote:Original post by Basement24
thanks you guys, now i seem to have solve that problem but now i want to make sure by testing on other pc's, but am getting mvscrc100.dll missing.


You either need to link the C++ runtime library statically or ship the Visual C++ 2010 Redistributable with your program.
If you use SDL_Delay to pad framerate, and then count the framerate, make sure to take count of it AFTER you ask for the delay because the time taken will differ from the time requested.

This topic is closed to new replies.

Advertisement