Advertisement

Frame Rate

Started by April 10, 2001 06:08 AM
1 comment, last by Eight 23 years, 10 months ago
Hi there, How do I go about calculating the frame rate of my code? Obviously it''s the number of frames updated per second, but where-abouts (and how) in my game loops is this figure calculated. Also, can anyone point me at some information about locking the frame-rate down to a fixed level. Many thanks, Eight
You can calculate your framerate like this, in pseudo-code:
  TimeCur = 0;TimeLast = 0;while(GetInput says not to quit) {  TimeLast = TimeCur;  TimeCur = GetCurrentTime();  TimePassed = TimeCur-TimeLast;  Output("Your frame rate is %f.", 1000.0f/TimePassed);  DoSomething();  Render();  Flip();}  

NEVER lock your frame rate! Just have it so that everything moves/happens at a rate perportional to the time that has passed. If you lock your framerate, to give crappy looking performance to good computers, and you cause even bigger problems for the people who can''t keep up with that locked frame rate.

"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
Resist Windows XP''s Invasive Production Activation Technology!
http://druidgames.cjb.net/
Advertisement
Ah right.

Simpler than I thought. I feel thick now.

Thanks for the help Null.

This topic is closed to new replies.

Advertisement