Archived

This topic is now archived and is closed to further replies.

nino

how to get framerate

Recommended Posts

nino    122
is there some sort of formula to use that can determine your current framerate? i''m using a timer to render at 60FPS but i want to check and see if it actually goes at that speed and if it ever slows down thanks NiNo

Share this post


Link to post
Share on other sites
BitBlt    386
Keep a variable that has the time elapsed since the last frame was drawn. Then divide 1 by this variable and you''ll have you''re framerate.



"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka

Share this post


Link to post
Share on other sites
paulcoz    230
nino,

Have a read about timers - you can find out about them in the docs of your compiler.

If you check the timer before you draw a frame, then check the timer after the frame you get a start and end time for one frame. Subtract the start time from the end time to get the time elapsed. Divide the time elasped (usually in ms) into 1000ms or 1 second to get the number of frames which will be drawn in a second. You may want to average this a little so it is less eratic.

Alternatively, you can get the start time for a particular frame, then each time you draw a frame add 1 to a frames counter, and get another timer (end time). Do this until the end time = start time + 1000ms.

Is that clearer?
Paulcoz.

Share this post


Link to post
Share on other sites
alistair b    122
i wrote a small function/tutorial to do this which uses nehe's timer function from lesson 21

it displays the fps as a bar at the bottom of the screen (which i find easier to read than a constantly changing number)

alistair

Edited by - alistair b on November 3, 2000 6:06:38 PM

Share this post


Link to post
Share on other sites