r/howdidtheycodeit • u/bluegreenjelly • Jul 28 '22
Question How Does FPS Limiting Work
It just dawned on me I have no idea how limiting FPS in an engine works.
The piece I'm most uncertain about is what to do with the time after you've hit the cap. For example, if cap at 60fps and we get through everything in 0.75 seconds what happens to the remaining 0.25? If the engine sits idle for that time until the next second, won't there be a notable jitter in either input handling or rendering as we wait for the 0.25 to expire? If that tracks and I haven't missed something, or am otherwise completely off, it seems to suggest there is some method of sequencing the 60 frames across the full second but I don't suspect you could possibly know how long a frame will take to calculate before it is going to be dealt with.
I hope the question I am asking in that paragraph is clear. I also think there is a whole lot about rendering that I'm not aware of so if that is the case I'd love to be taught.
View all comments
Show parent comment
5
u/bluegreenjelly Jul 28 '22
Thanks for the response. You're right about me thinking about the math wrong. I wasn't considering at all that you get a target ms to hit between frames. That was the main piece of the puzzle I was missing.
I had encountered double buffering once upon a time in my learning journeys but didn't fully get it then. Maybe this time I'll grasp it better :P