Permalink
Browse files

comment codes for FPS controlling

  • Loading branch information...
1 parent ab1621f commit e3fca132ce1b78f19370c91f83c7d5168e60bd26 @minggo minggo committed Nov 30, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java
View
11 cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java
@@ -79,23 +79,32 @@ public void onSurfaceChanged(final GL10 pGL10, final int pWidth, final int pHeig
@Override
public void onDrawFrame(final GL10 gl) {
+ /*
+ * FPS controlling algorithm is not accurate, and it will slow down FPS
+ * on some devices. So comment FPS controlling code.
+ */
+
+ /*
final long nowInNanoSeconds = System.nanoTime();
final long interval = nowInNanoSeconds - this.mLastTickInNanoSeconds;
+ */
// should render a frame when onDrawFrame() is called or there is a
// "ghost"
Cocos2dxRenderer.nativeRender();
+ /*
// fps controlling
if (interval < Cocos2dxRenderer.sAnimationInterval) {
try {
// because we render it before, so we should sleep twice time interval
- Thread.sleep((Cocos2dxRenderer.sAnimationInterval - interval) * 2 / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
+ Thread.sleep((Cocos2dxRenderer.sAnimationInterval - interval) / Cocos2dxRenderer.NANOSECONDSPERMICROSECOND);
} catch (final Exception e) {
}
}
this.mLastTickInNanoSeconds = nowInNanoSeconds;
+ */
}
// ===========================================================

4 comments on commit e3fca13

@yihuang

Hello, what's the status of this code? We've found flickering on android, while frame rate shown is high.
And i don't understand this fps controlling algorithm at all.

@minggo

The fps controlling codes are commented.
So there is not fps controlling codes.

@yihuang

Is this the final version? Wouldn't it cause cpu too busy?

@minggo

There is not a suitable algoritm of fps controlling.
It will slow down application using this algoritm on some conditions.
So i let the developer to turn it if it is needed.

Please sign in to comment.