FPS bug (solved?)

i found a bug in the idle_cb function that was responsible for wrong wait-times and thus wrong load balancing.
the measurement of time didn’t include the update function. because i had quite a lot going on in my update function (lua-scripts, physics simulation etc.) my framerate got worse and worse though the processor was not even using 30% of available cpu-time.
the corrected idle_cb should be like this:

  
void idle_cb(void) {  
  
	if (nFrameCount != 0 && bFrameRateSet == true){  
		diffMillis = ofGetElapsedTimeMillis() - prevMillis;  
		if (diffMillis > millisForFrame){  
			; // we do nothing, we are already slower than target frame  
		} else {  
			int waitMillis = millisForFrame - diffMillis;   
			#ifdef TARGET_WIN32  
				Sleep(waitMillis);			//windows sleep in milliseconds  
			#else  
				usleep(waitMillis * 1000);	//mac sleep in microseconds - cooler :)  
			#endif   
		}	  
	}   
  
	prevMillis = ofGetElapsedTimeMillis(); // you have to measure here  
	OFSAptr->update();  
	glutPostRedisplay();  
}  

now my fps rate is rock solid!
i hope this can still make it into 0.05.

best
joerg

thanks. i tried it but did not give me any boost :frowning:
is this in OF_v00.5 btw?

fixed in 0.05
zach

thx for the info, zach