MCPcopy Create free account
hub / github.com/cinder/Cinder / sleepUntilNextFrame

Method sleepUntilNextFrame

src/cinder/app/android/AppImplAndroid.cpp:124–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void AppImplAndroid::sleepUntilNextFrame()
125{
126 // get current time in seconds
127 double currentSeconds = getElapsedSeconds();
128
129 // calculate time per frame in seconds
130 double secondsPerFrame = 1.0 / mFrameRate;
131
132 // determine if application was frozen for a while and adjust next frame time
133 double elapsedSeconds = currentSeconds - mNextFrameTime;
134 if( elapsedSeconds > 1.0 ) {
135 int numSkipFrames = (int)(elapsedSeconds / secondsPerFrame);
136 mNextFrameTime += (numSkipFrames * secondsPerFrame);
137 }
138
139 // determine when next frame should be drawn
140 mNextFrameTime += secondsPerFrame;
141
142 // sleep and process messages until next frame
143 if( ( mFrameRateEnabled ) && ( mNextFrameTime > currentSeconds ) ) {
144 double sleepTime = std::max( mNextFrameTime - currentSeconds, 0.0 );
145 unsigned long sleepMicroSecs = sleepTime*1000000L;
146 usleep(sleepMicroSecs);
147 }
148}
149
150void AppImplAndroid::updateAndDraw()
151{

Callers 1

executeMethod · 0.45

Calls 2

getElapsedSecondsFunction · 0.50
maxFunction · 0.50

Tested by

no test coverage detected