[CSC 415] Computing FPS
Timothy Herold
timothy.herold at gmail.com
Sun Jan 23 22:28:40 EST 2011
Hello everyone,
I did a little research and I think this is the way to go for computing our
frames per second easily.
GLUT has a built in value for GLUT_ELAPSED_TIME which records the number of
milliseconds since the last call to glutInit().
So here's what we do.
// frames: the number of frames since FPS was last calculated
// time: the current time elapsed
// time2: the time elapsed since FPS was last calculated
int fps, frames, time, time2;
frames=0;
time=0;
// put the following into the idle function
frame++;
time=glutGet(GLUT_ELAPSED_TIME);
if ( time - time2 > 1000 ) { // or however often we want to update FPS
fps = frames * 1000.0 / ( time - time2 );
time = time2;
frames = 0;
}
and voila, FPS without using system calls for time.
--
Timothy Herold
timothy.herold at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://theochem.mercer.edu/pipermail/csc415/attachments/20110123/da312f10/attachment.html
More information about the csc415
mailing list