I have a question about my code. I wrote a basic GameLoop for an Android Game and while testing it I realized the deltaTime is always 0.
The code looks like this:
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
lastTime = System.currentTimeMillis();
}
@Override
public void onDrawFrame(GL10 gl) {
float currTime = System.currentTimeMillis();
float deltaTime = currTime - lastTime;
float msPerFrame = 1000.0f/ 60.0f;
if(deltaTime < msPerFrame){
try {
Thread.sleep((long)(msPerFrame-deltaTime));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
update(deltaTime, gl);
lastTime = currTime;
}
public void update(float deltaTime, GL10 gl){
//doStuff
}
lastTime and currTime are always the same and the deltaTime is 0. I don't know if this is right or the code is just wrong but I think the deltaTime shouldn't be 0...
I test the app with Android Studios Emulator.