Hello everyone,<div><br></div><div>I did a little research and I think this is the way to go for computing our frames per second easily.</div><div><br></div><div>GLUT has a built in value for GLUT_ELAPSED_TIME which records the number of milliseconds since the last call to glutInit().</div>
<div><br></div><div>So here's what we do.</div><div><br></div><div>// frames: the number of frames since FPS was last calculated</div><div>// time: the current time elapsed</div><div>// time2: the time elapsed since FPS was last calculated</div>
<div>int fps, frames, time, time2;</div><div><br></div><div>frames=0;</div><div>time=0;</div><div><br></div><div>// put the following into the idle function</div><div><br></div><div>frame++;</div><div>time=glutGet(GLUT_ELAPSED_TIME);</div>
<div>if ( time - time2 > 1000 ) { // or however often we want to update FPS</div><div> fps = frames * 1000.0 / ( time - time2 );</div><div> time = time2;</div><div> frames = 0;</div><div>}</div><div><br></div>
<div>and voila, FPS without using system calls for time.</div><div><br>-- <br>Timothy Herold<br><a href="mailto:timothy.herold@gmail.com">timothy.herold@gmail.com</a><br>
</div>