Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class G3MBuilder_Android

private final G3MWidget_Android _nativeWidget;


public G3MBuilder_Android(final Context context) {
super();

Expand Down Expand Up @@ -92,5 +91,13 @@ protected IDownloader createDefaultDownloader() {
saveInBackground);
}


/**
* Sets the _FPSReduction
*
* @param FPSReduction
*/
public final void setFPSReduction(boolean FPSReduction)
{
_nativeWidget.setFPSReduction(FPSReduction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -453,5 +454,11 @@ public G3MContext getG3MContext() {
return getG3MWidget().getG3MContext();
}

public void setFPSReduction(boolean FPSReduction) {
_FPSReduction = FPSReduction;
}

public boolean getFPSReduction() {
return _FPSReduction;
}
}