diff --git a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java index 01aa480640..3a30eb8f54 100644 --- a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java +++ b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/ES2Renderer.java @@ -62,29 +62,28 @@ public void onDrawFrame(final GL10 glUnused) { final G3MWidget widget = _widgetAndroid.getG3MWidget(); widget.render(_width, _height); - // experimental FPS reduction - DGD - final long now = System.currentTimeMillis(); - final long timeElapsedInRender = now - _startTime; - final long timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; - if (timeLeftInMS > 0) { - // System.gc(); - // - // timeElapsedInRender = System.currentTimeMillis() - _startTime; - // timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; - // if (timeLeftInMS > 0) { - try { - //ILogger.instance().logInfo("**** sleeping OpenGL thread for " + timeLeftInMS + "ms"); - Thread.sleep(timeLeftInMS); + if (_widgetAndroid.getFPSReduction()) { + // experimental FPS reduction - DGD + final long now = System.currentTimeMillis(); + final long timeElapsedInRender = now - _startTime; + final long timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; + if (timeLeftInMS > 0) { + // System.gc(); + // + // timeElapsedInRender = System.currentTimeMillis() - _startTime; + // timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender; + // if (timeLeftInMS > 0) { + try { + //ILogger.instance().logInfo("**** sleeping OpenGL thread for " + timeLeftInMS + "ms"); + Thread.sleep(timeLeftInMS); + } catch (final InterruptedException e) { + } + // } + _startTime = System.currentTimeMillis(); + } else { + _startTime = now; } - catch (final InterruptedException e) { - } - // } - _startTime = System.currentTimeMillis(); - } - else { - _startTime = now; } - } diff --git a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java index 0b37e865a0..abbadc819e 100644 --- a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java +++ b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MBuilder_Android.java @@ -19,7 +19,6 @@ public class G3MBuilder_Android private final G3MWidget_Android _nativeWidget; - public G3MBuilder_Android(final Context context) { super(); @@ -92,5 +91,13 @@ protected IDownloader createDefaultDownloader() { saveInBackground); } - + /** + * Sets the _FPSReduction + * + * @param FPSReduction + */ + public final void setFPSReduction(boolean FPSReduction) + { + _nativeWidget.setFPSReduction(FPSReduction); + } } diff --git a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java index 2adfed7374..2bec7f3446 100644 --- a/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java +++ b/Android/G3MAndroidSDK/src/org/glob3/mobile/specific/G3MWidget_Android.java @@ -61,7 +61,7 @@ public final class G3MWidget_Android private final OnDoubleTapListener _doubleTapListener; private final GestureDetector _gestureDetector; private Thread _openGLThread = null; - + private boolean _FPSReduction; public G3MWidget_Android(final android.content.Context context) { this(context, null); @@ -83,12 +83,13 @@ public final void checkOpenGLThread() { } } - // Needed to create widget from XML layout public G3MWidget_Android(final android.content.Context context, final AttributeSet attrs) { super(context, attrs); + _FPSReduction = true; + initSingletons(); setEGLContextClientVersion(2); // OPENGL ES VERSION MUST BE SPECIFED @@ -453,5 +454,11 @@ public G3MContext getG3MContext() { return getG3MWidget().getG3MContext(); } + public void setFPSReduction(boolean FPSReduction) { + _FPSReduction = FPSReduction; + } + public boolean getFPSReduction() { + return _FPSReduction; + } }