summaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-02-21 10:04:34 +0000
committerKenneth Russel <[email protected]>2006-02-21 10:04:34 +0000
commitb0cd74f86140937ce73b740602b0bf79dbfd8f11 (patch)
tree8cdaec339c2da241b8fc9ddced399885bc159dd2 /src/classes/com/sun/opengl
parent36887db6c983244917802f3ec761a0d28171887a (diff)
Fixed Issue 205: FPSAnimator flag for fixed-rate scheduling
Added new constructors taking fixed-rate scheduling flag. Defaults to false. Seems to help FPSAnimator reach higher framerate targets. Unclear whether the flag will cause excessive CPU consumption. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@630 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl')
-rwxr-xr-xsrc/classes/com/sun/opengl/util/FPSAnimator.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/classes/com/sun/opengl/util/FPSAnimator.java b/src/classes/com/sun/opengl/util/FPSAnimator.java
index fae0ce0ae..290de89d6 100755
--- a/src/classes/com/sun/opengl/util/FPSAnimator.java
+++ b/src/classes/com/sun/opengl/util/FPSAnimator.java
@@ -49,19 +49,38 @@ import javax.media.opengl.*;
public class FPSAnimator extends Animator {
private Timer timer;
private int fps;
+ private boolean scheduleAtFixedRate;
- /** Creates an FPSAnimator with a given target frames-per-second value. */
+ /** Creates an FPSAnimator with a given target frames-per-second
+ value. Equivalent to <code>FPSAnimator(null, fps)</code>. */
public FPSAnimator(int fps) {
this(null, fps);
}
/** Creates an FPSAnimator with a given target frames-per-second
- value and an initial drawable to animate. */
+ value and a flag indicating whether to use fixed-rate
+ scheduling. Equivalent to <code>FPSAnimator(null, fps,
+ scheduleAtFixedRate)</code>. */
+ public FPSAnimator(int fps, boolean scheduleAtFixedRate) {
+ this(null, fps, scheduleAtFixedRate);
+ }
+
+ /** Creates an FPSAnimator with a given target frames-per-second
+ value and an initial drawable to animate. Equivalent to
+ <code>FPSAnimator(null, fps, false)</code>. */
public FPSAnimator(GLAutoDrawable drawable, int fps) {
+ this(drawable, fps, false);
+ }
+
+ /** Creates an FPSAnimator with a given target frames-per-second
+ value, an initial drawable to animate, and a flag indicating
+ whether to use fixed-rate scheduling. */
+ public FPSAnimator(GLAutoDrawable drawable, int fps, boolean scheduleAtFixedRate) {
this.fps = fps;
if (drawable != null) {
add(drawable);
}
+ this.scheduleAtFixedRate = scheduleAtFixedRate;
}
/** Starts this FPSAnimator. */
@@ -71,11 +90,16 @@ public class FPSAnimator extends Animator {
}
timer = new Timer();
long delay = (long) (1000.0f / (float) fps);
- timer.schedule(new TimerTask() {
+ TimerTask task = new TimerTask() {
public void run() {
display();
}
- }, 0, delay);
+ };
+ if (scheduleAtFixedRate) {
+ timer.scheduleAtFixedRate(task, 0, delay);
+ } else {
+ timer.schedule(task, 0, delay);
+ }
}
/** Indicates whether this FPSAnimator is currently running. This