how to get framerate

Started by
4 comments, last by nino 23 years, 5 months ago
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
Advertisement
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
thanks but i''m not sure i understand what you mean could you be more specific?

thanks
NiNo
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.
you find the starting time for the loop via timeGetTime, or QueeryPerformanceCounter, or whatever. Then you find the ending time of that same loop. You convert milliseconds to seconds. you take 1/end-start and walla.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
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

This topic is closed to new replies.

Advertisement