Yet one more post about FPS

Started by
2 comments, last by Peachy keen 17 years, 9 months ago
Hello all For a while now I’ve been wondering about one thing. This is what I do to lock the frame rate: if (frame_time >= (1.0f / 50)) { //do things } In this case the locked FPS rate should be 50. Well it isn’t. It gets close when the frame rate is very high or when it drops below 50. My understanding of this phenomenon is that 1/50 isn’t an integer value and the probability that the frame time would equal exactly 1/50 is infinitely low. This is why the more FPS the more accurate locked FPS get. In some games, however, I’ve seen the locked frame rate constant all the time and I’ve been wondering if there are some tricks to achieve this? Thank you
Advertisement
What function do you use to get the frame time? If its GetTickCount() that might be a reason.

Even with a high performance timer it's impossible to get a perfectly constant framerate. They prolly just round it off and even then, if they would display the framerate each frame youd certainly see it go up and down.

[Edited by - ronkfist on August 6, 2006 10:20:18 AM]
I use QueryPerformanceFrequency.

So locked frame rate isn't actually locked?
Locked frame rate is approximately locked. If you 'lock your framerate', with any sort of function set, at 'x', and you call your renderer 'x' times a second, You're going to get a frame rate that averages to 'x' frames a second, but the individual frames aren't always going to be spot-on at 1/'x' seconds apart. Even in the code you write, you get the timing perfect within your game, you're running in a multi-threaded environment, and that'll throw a bit of noise into your equations simply because your program isn't always on the processor. If you lock your frame rate to, for example, 50 frames a second, and are getting a calculated frame rate of 49, or 46 [if you lock the time, you're not likely to see framerates larger than that which you lock it to, since it'll fail the condition required to render to screen], then you can generally consider your framerate pretty much set.

Oh, and the lower frame rate you shoot for to lock it to, the more likely you'll have calculated values within that range, since the context switching, processor load, and various other performance anomalies will not really throw it too much. A locked rate of 75 fps will see some noise, and might drop down to 69 with no real noticable difference, but a game locked something silly like 5 fps is not likely to ever drop down to 3, under the same kind of load as the 75 fps game :P

In other words, a 'locked fps' is an upper bound that you are attempting to converge to.

This topic is closed to new replies.

Advertisement