Forgot to update the commit text
This commit is contained in:
parent
5948479de4
commit
47477daa05
@ -88,13 +88,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
*/
|
*/
|
||||||
protected int eglStencilBits = 0;
|
protected int eglStencilBits = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the desired frame rate. If frameRate > 0, the application
|
|
||||||
* will be capped at the desired frame rate.
|
|
||||||
* (default = -1, no frame rate cap)
|
|
||||||
*/
|
|
||||||
protected int frameRate = -1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the type of Audio Renderer to be used.
|
* Sets the type of Audio Renderer to be used.
|
||||||
* <p>
|
* <p>
|
||||||
@ -246,8 +239,6 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
|
|||||||
settings.setResolution(disp.getWidth(), disp.getHeight());
|
settings.setResolution(disp.getWidth(), disp.getHeight());
|
||||||
settings.setAudioRenderer(audioRendererType);
|
settings.setAudioRenderer(audioRendererType);
|
||||||
|
|
||||||
settings.setFrameRate(frameRate);
|
|
||||||
|
|
||||||
// Create application instance
|
// Create application instance
|
||||||
try {
|
try {
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
|
@ -75,8 +75,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
protected SystemListener listener;
|
protected SystemListener listener;
|
||||||
protected boolean autoFlush = true;
|
protected boolean autoFlush = true;
|
||||||
protected AndroidInputHandler androidInput;
|
protected AndroidInputHandler androidInput;
|
||||||
protected long minFrameDuration = 0; // No FPS cap
|
protected int minFrameDuration = 0; // No FPS cap
|
||||||
protected long lastUpdateTime = 0;
|
|
||||||
protected JoyInput androidSensorJoyInput = null;
|
protected JoyInput androidSensorJoyInput = null;
|
||||||
|
|
||||||
public OGLESContext() {
|
public OGLESContext() {
|
||||||
@ -226,12 +225,6 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
androidInput.loadSettings(settings);
|
androidInput.loadSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.getFrameRate() > 0) {
|
|
||||||
minFrameDuration = (long)(1000d / (double)settings.getFrameRate()); // ms
|
|
||||||
logger.log(Level.FINE, "Setting min tpf: {0}ms", minFrameDuration);
|
|
||||||
} else {
|
|
||||||
minFrameDuration = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -327,25 +320,23 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
throw new IllegalStateException("onDrawFrame without create");
|
throw new IllegalStateException("onDrawFrame without create");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long milliStart = System.currentTimeMillis();
|
||||||
|
|
||||||
listener.update();
|
listener.update();
|
||||||
if (autoFlush) {
|
if (autoFlush) {
|
||||||
renderer.onFrame();
|
renderer.onFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
long updateDelta = System.currentTimeMillis() - lastUpdateTime;
|
long milliDelta = System.currentTimeMillis() - milliStart;
|
||||||
|
|
||||||
// Enforce a FPS cap
|
// Enforce a FPS cap
|
||||||
if (updateDelta < minFrameDuration) {
|
if (milliDelta < minFrameDuration) {
|
||||||
// logger.log(Level.INFO, "lastUpdateTime: {0}, updateDelta: {1}, minTimePerFrame: {2}",
|
//logger.log(Level.FINE, "Time per frame {0}", milliDelta);
|
||||||
// new Object[]{lastUpdateTime, updateDelta, minTimePerFrame});
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(minFrameDuration - updateDelta);
|
Thread.sleep(minFrameDuration - milliDelta);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastUpdateTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user