summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/Animator.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java25
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java9
3 files changed, 21 insertions, 15 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index 5d48405e2..2b8876a91 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -197,6 +197,7 @@ public class Animator extends AnimatorBase {
if (runnable == null) {
runnable = new MainLoop();
}
+ resetCounter();
int id;
String threadName = Thread.currentThread().getName()+"-"+baseName;
if(null==threadGroup) {
@@ -272,6 +273,7 @@ public class Animator extends AnimatorBase {
}
}
}
+ resetCounter();
}
protected final boolean getShouldPause() {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
index 279fe33ef..a54f6be57 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java
@@ -49,9 +49,9 @@ public abstract class AnimatorBase implements GLAnimatorControl {
protected Thread thread;
protected boolean ignoreExceptions;
protected boolean printExceptions;
- protected long startTime = 0;
- protected long curTime = 0;
- protected int totalFrames = 0;
+ protected long startTime;
+ protected long curTime;
+ protected int totalFrames;
/** Creates a new, empty Animator. */
public AnimatorBase() {
@@ -69,6 +69,7 @@ public abstract class AnimatorBase implements GLAnimatorControl {
animatorCount++;
baseName = baseName.concat("-"+animatorCount);
}
+ resetCounter();
}
protected abstract String getBaseName(String prefix);
@@ -112,10 +113,6 @@ public abstract class AnimatorBase implements GLAnimatorControl {
return curTime - startTime;
}
- protected abstract boolean getShouldPause();
-
- protected abstract boolean getShouldStop();
-
public long getStartTime() {
return startTime;
}
@@ -124,6 +121,12 @@ public abstract class AnimatorBase implements GLAnimatorControl {
return totalFrames;
}
+ public synchronized void resetCounter() {
+ startTime = System.currentTimeMillis(); // overwrite startTime to real init one
+ curTime = startTime;
+ totalFrames = 0;
+ }
+
public final synchronized Thread getThread() {
return thread;
}
@@ -142,4 +145,12 @@ public abstract class AnimatorBase implements GLAnimatorControl {
public void setPrintExceptions(boolean printExceptions) {
this.printExceptions = printExceptions;
}
+
+ public String toString() {
+ return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", frames "+getTotalFrames()+"]";
+ }
+
+ protected abstract boolean getShouldPause();
+
+ protected abstract boolean getShouldStop();
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
index d098cf1a3..8542000c6 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
@@ -88,11 +88,6 @@ public class FPSAnimator extends AnimatorBase {
this.scheduleAtFixedRate = scheduleAtFixedRate;
}
- public long getStartTime() { return startTime; }
- public long getCurrentTime() { return curTime; }
- public long getDuration() { return curTime-startTime; }
- public int getTotalFrames() { return totalFrames; }
-
public final synchronized boolean isStarted() {
return (timer != null);
}
@@ -116,9 +111,7 @@ public class FPSAnimator extends AnimatorBase {
}
};
- startTime = System.currentTimeMillis();
- curTime = startTime;
- totalFrames = 0;
+ resetCounter();
shouldRun = true;
if (scheduleAtFixedRate) {