openframeworks/openFrameworks — pull request #1585 by arturoc (2012-09-08 12:21:50+00:00)
Title: ofAppGlutWindow: fix fps calculation and makes setFramerate more accurate

ofGetFrameRate was returning strange values when the gl load was high. Sometimes when the gl task is to gpu intensive it seems to skip a frame draw which gives really short times for one frame. since the fps calculation was accumulating old values this makes the fps go higher. in general this makes the fps go up to about 70-80fps while the total frames in one second is really about 60fps even when this happens. In some systems i've seen it go to even 300-400fps when the real framerate was 60

This commit fixes that problem + makes ofSetFrameRate more accurate by using microseconds where available (osx and linux) I've tested this reading the max and min times per frame setting the framerate and in an empty application the difference between the min and max times per frame are of about 0.1ms

would be good to test in other systems to check that it doesn't break, mostly on windows where sleep only works with milliseconds so the calculations are different and i might have introduced an error

if this works properly it would be good to move this calculation to ofNotifyUpdate so different windowing systems don't need to replicate this code