Hi,
My game loop occasionally has problems. I have a first person camera and generally speaking I get smooth movement. But for some reason once in a while for days my forward/strafe movement becomes choppy. I investigated a little, and what was going on is that the time delta between loops was coming out as 0 and would only be a larger amount every 6 or 7 loop cycles. Here is the gist of my loop:
lastTime = getTime();
fpsTime = getTime();
while (!Display.isCloseRequested() &&
!Keyboard.isKeyDown(Keyboard.KEY_Q))
{
framesPassed++;
time = getTime();
//System.out.println("Current time: " + time + ", lastTime: " + lastTime);
dt = time - lastTime;
lastTime = time;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
GLUtil.logError(-10, 0);
glLoadIdentity();
updateScene(dt);
renderScene(dt);
updateFPS(dt);
Display.update();
Display.sync(60);
}
return true;
This seemed like a fairly simple game loop to me. I looked through some of the threads in this forum and there was some fairly complicated stuff going on. However, then I thought, for some reason, my mouse look is not choppy at all, even when the movement is choppy. Surely this must mean there is some other problem? Anyone have an idea about what might be going on?