summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-22 12:46:19 +0100
committerSven Gothel <[email protected]>2010-11-22 12:46:19 +0100
commit4c3e9e258fae1161949dd14828c09f387bfd53d9 (patch)
treea8b287153f6afbf166db85506af4c3790590663d /src/jogl/classes
parent6a3ccca96e6d4c27c372b4b9ba1e8fcee6def402 (diff)
GLAnimatorControl pause()/resume() don't fail fast, return a boolean instead to simplify usage.
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/Animator.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/GLAnimatorControl.java14
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java5
4 files changed, 22 insertions, 19 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index 2d4727bba..31abe099d 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -294,9 +294,9 @@ public class Animator extends AnimatorBase {
}
Condition waitForStoppedCondition = new WaitForStoppedCondition();
- public synchronized void pause() {
+ public synchronized boolean pause() {
if ( !isStartedImpl() || pauseIssued ) {
- throw new GLException("Pause: Invalid state (started "+isStartedImpl()+" (true), paused "+pauseIssued+" (false) )");
+ return false;
}
stateSync.lock();
try {
@@ -306,6 +306,7 @@ public class Animator extends AnimatorBase {
}
notifyAll();
finishLifecycleAction(waitForPausedCondition);
+ return true;
}
private class WaitForPausedCondition implements Condition {
public boolean result() {
@@ -315,9 +316,9 @@ public class Animator extends AnimatorBase {
}
Condition waitForPausedCondition = new WaitForPausedCondition();
- public synchronized void resume() {
+ public synchronized boolean resume() {
if ( !isStartedImpl() || !pauseIssued ) {
- throw new GLException("Resume: Invalid state (started "+isStartedImpl()+" (true), paused "+pauseIssued+" (true) )");
+ return false;
}
stateSync.lock();
try {
@@ -327,6 +328,7 @@ public class Animator extends AnimatorBase {
}
notifyAll();
finishLifecycleAction(waitForResumeCondition);
+ return true;
}
private class WaitForResumeCondition implements Condition {
public boolean result() {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
index 447c72709..6bac1646b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java
@@ -170,9 +170,9 @@ public class FPSAnimator extends AnimatorBase {
}
}
- public synchronized void pause() {
+ public synchronized boolean pause() {
if (timer == null) {
- throw new GLException("Not running");
+ return false;
}
stateSync.lock();
try {
@@ -183,17 +183,19 @@ public class FPSAnimator extends AnimatorBase {
} finally {
stateSync.unlock();
}
+ return true;
}
- public synchronized void resume() {
+ public synchronized boolean resume() {
if (timer == null) {
- throw new GLException("Not running");
+ return false;
}
stateSync.lock();
try {
startTask();
} finally {
stateSync.unlock();
- }
+ }
+ return true;
}
}
diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
index 98d7bc48b..0282b3ad0 100644
--- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
+++ b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java
@@ -32,8 +32,8 @@ package javax.media.opengl;
* An animator control interface,
* which implementation may drive a {@link javax.media.opengl.GLAutoDrawable} animation.
* <P>
- * Note that the methods {@link #start()}, {@link #stop()}, {@link #pause()} and {@link #resume()}
- * shall be implemented to fail-fast, ie {@link #start()} fails if not started, etc.
+ * Note that the methods {@link #start()} and {@link #stop()}
+ * shall be implemented fail-fast, ie {@link #start()} fails if not started, etc.
* This way an implementation can find implementation errors faster.
*/
public interface GLAnimatorControl {
@@ -157,11 +157,12 @@ public interface GLAnimatorControl {
* or in some cases from an implementation-internal thread like the
* AWT event queue thread.
*
+ * @return false if if not started or already paused, otherwise true
+ *
* @see #resume()
* @see #isAnimating()
- * @throws GLException if not started or already paused
*/
- void pause();
+ boolean pause();
/**
* Resumes animation if paused.
@@ -173,11 +174,12 @@ public interface GLAnimatorControl {
* <P>
* If resumed, all counters (time, frames, ..) are reset to zero.
*
+ * @return false if if not started or not paused, otherwise true
+ *
* @see #pause()
* @see #isAnimating()
- * @throws GLException if not started or not paused
*/
- void resume();
+ boolean resume();
/**
* Removes a drawable from the animator's list of rendering drawables.<br>
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 265c7ff49..b2d919eaf 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -351,10 +351,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable {
GLAnimatorControl animator = getAnimator();
if(null!=animator) {
if(regenerate) {
- if(animator.isStarted() && !animator.isPaused()) {
- animator.pause();
- animatorPaused = true;
- }
+ animatorPaused = animator.pause();
} else {
animator.remove(this);
}