From a16f7c2268c1703020c563572d63c3eed663cac0 Mon Sep 17 00:00:00 2001 From: Caspian Rychlik-Prince Date: Fri, 3 Dec 2004 00:54:01 +0000 Subject: [PATCH] Fixed timer wrapping problem --- src/java/org/lwjgl/util/Timer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/java/org/lwjgl/util/Timer.java b/src/java/org/lwjgl/util/Timer.java index 554e0cf6..30c81fab 100644 --- a/src/java/org/lwjgl/util/Timer.java +++ b/src/java/org/lwjgl/util/Timer.java @@ -77,8 +77,16 @@ public class Timer { * @return the time in seconds, as a float */ public float getTime() { - if (!paused) - lastTime = currentTime - startTime; + if (!paused) { + if (currentTime > startTime) { + lastTime = currentTime - startTime; + } else { + // The timer seems to have wrapped round. We don't know + // when it wrapped round, so the only thing we can reasonably + // do is reset the starttime and have a "glitch" + startTime = currentTime; + } + } return (float) ((double) lastTime / (double) resolution); }