diff options
Diffstat (limited to 'src/jogl/classes/com')
3 files changed, 177 insertions, 37 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 10b0b6b5a..b03b6956b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -45,6 +45,7 @@ import com.jogamp.common.util.InterruptSource; import com.jogamp.common.util.SourcedInterruptedException; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLException; +import com.jogamp.opengl.GLProfile; /** <P> An Animator can be attached to one or more {@link GLAutoDrawable}s to drive their display() methods in a loop. </P> @@ -69,46 +70,100 @@ public class Animator extends AnimatorBase { volatile boolean stopIssued; /** - * Creates a new, empty Animator. + * Creates a new, empty Animator instance + * while expecting an AWT rendering thread if AWT is available. + * + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #Animator(int, ThreadGroup, GLAutoDrawable) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) */ public Animator() { - super(); - if(DEBUG) { - System.err.println("Animator created"); - } + this(MODE_EXPECT_AWT_RENDERING_THREAD, null, null); + } + + /** + * Creates a new, empty Animator instance + * with given modeBits. + * <p> + * Passing {@link AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD} is considered default. + * However, passing {@code 0} is recommended if not using AWT in your application. + * </p> + * + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #Animator(int, ThreadGroup, GLAutoDrawable) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ + public Animator(final int modeBits) { + this(modeBits, null, null); } /** * Creates a new Animator w/ an associated ThreadGroup. + * <p> + * This ctor variant expects an AWT rendering thread if AWT is available. + * </p> + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #Animator(int, ThreadGroup, GLAutoDrawable) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) */ public Animator(final ThreadGroup tg) { - super(); - setThreadGroup(tg); - if(DEBUG) { - System.err.println("Animator created, ThreadGroup: "+threadGroup); - } + this(MODE_EXPECT_AWT_RENDERING_THREAD, tg, null); } /** * Creates a new Animator for a particular drawable. + * <p> + * This ctor variant expects an AWT rendering thread if AWT is available. + * </p> + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #Animator(int, ThreadGroup, GLAutoDrawable) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) */ public Animator(final GLAutoDrawable drawable) { - super(); - add(drawable); - if(DEBUG) { - System.err.println("Animator created, w/ "+drawable); - } + this(MODE_EXPECT_AWT_RENDERING_THREAD, null, drawable); } /** * Creates a new Animator w/ an associated ThreadGroup for a particular drawable. + * <p> + * This ctor variant expects an AWT rendering thread if AWT is available. + * </p> + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #Animator(int, ThreadGroup, GLAutoDrawable) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) */ public Animator(final ThreadGroup tg, final GLAutoDrawable drawable) { - super(); - setThreadGroup(tg); - add(drawable); + this(MODE_EXPECT_AWT_RENDERING_THREAD, tg, drawable); + } + + /** + * Creates a new Animator w/ an associated ThreadGroup for a particular drawable. + * <p> + * Passing {@link AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD} is considered default. + * However, passing {@code 0} is recommended if not using AWT in your application. + * </p> + * @param modeBits pass {@link AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD} if an AWT rendering thread is expected, otherwise {@code 0}. + * @param tg desired {@link ThreadGroup} or {@code null} + * @param drawable {@link #add(GLAutoDrawable) added} {@link GLAutoDrawable} or {@code null} + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ + public Animator(final int modeBits, final ThreadGroup tg, final GLAutoDrawable drawable) { + super(modeBits); + if( null != tg ) { + setThreadGroup(tg); + } + if( null != drawable ) { + add(drawable); + } if(DEBUG) { - System.err.println("Animator created, ThreadGroup: "+threadGroup+" and "+drawable); + System.err.println("Animator created, modeBits 0x"+Integer.toHexString(modeBits)+", ThreadGroup: "+threadGroup+" and "+drawable); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index c2da68cd9..6c776b064 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -129,10 +129,28 @@ public abstract class AnimatorBase implements GLAnimatorControl { * Creates a new, empty Animator instance * while expecting an AWT rendering thread if AWT is available. * + * @see #AnimatorBase(int) * @see GLProfile#isAWTAvailable() + * @see #setModeBits(boolean, int) */ public AnimatorBase() { - modeBits = MODE_EXPECT_AWT_RENDERING_THREAD; // default! + this( MODE_EXPECT_AWT_RENDERING_THREAD ); // default! + } + + /** + * Creates a new, empty Animator instance + * with given modeBits. + * <p> + * Passing {@link #MODE_EXPECT_AWT_RENDERING_THREAD} is considered default. + * However, passing {@code 0} is recommended if not using AWT in your application. + * </p> + * + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see GLProfile#isAWTAvailable() + * @see #setModeBits(boolean, int) + */ + public AnimatorBase(final int modeBits) { + this.modeBits = modeBits; drawablesEmpty = true; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 320873ede..b4dc139d4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -44,7 +44,7 @@ import java.util.TimerTask; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLException; - +import com.jogamp.opengl.GLProfile; import com.jogamp.common.ExceptionUtils; /** @@ -71,32 +71,99 @@ public class FPSAnimator extends AnimatorBase { return "FPS" + prefix + "Animator" ; } - /** Creates an FPSAnimator with a given target frames-per-second - value. Equivalent to <code>FPSAnimator(null, fps)</code>. */ + /** + * Creates an FPSAnimator with a given target frames-per-second + * value. Equivalent to <code>FPSAnimator(null, fps)</code>. + * <p> + * This ctor variant expects an AWT rendering thread if AWT is available. + * </p> + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #FPSAnimator(int, GLAutoDrawable, int, boolean) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ public FPSAnimator(final int fps) { - this(null, fps); + this(MODE_EXPECT_AWT_RENDERING_THREAD, null, fps, false); } - /** Creates an FPSAnimator with a given target frames-per-second - value and a flag indicating whether to use fixed-rate - scheduling. Equivalent to <code>FPSAnimator(null, fps, - scheduleAtFixedRate)</code>. */ + /** + * Creates an FPSAnimator with modeBits, see {@link AnimatorBase#AnimatorBase(int)} + * and a given target frames-per-second value. + * + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #FPSAnimator(int, GLAutoDrawable, int, boolean) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ + public FPSAnimator(final int modeBits, final int fps) { + this(modeBits, null, fps, false); + } + + /** + * Creates an FPSAnimator with a given target frames-per-second + * value and a flag indicating whether to use fixed-rate + * scheduling. Equivalent to <code>FPSAnimator(null, fps, + * scheduleAtFixedRate)</code>. + * <p> + * This ctor variant expects an AWT rendering thread if AWT is available. + * </p> + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #FPSAnimator(int, GLAutoDrawable, int, boolean) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ public FPSAnimator(final int fps, final boolean scheduleAtFixedRate) { - this(null, fps, scheduleAtFixedRate); + this(MODE_EXPECT_AWT_RENDERING_THREAD, 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>. */ + /** + * 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>. + * <p> + * This ctor variant expects an AWT rendering thread if AWT is available. + * </p> + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #FPSAnimator(int, GLAutoDrawable, int, boolean) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ public FPSAnimator(final GLAutoDrawable drawable, final int fps) { - this(drawable, fps, false); + this(MODE_EXPECT_AWT_RENDERING_THREAD, 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. */ + /** + * 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. + * <p> + * This ctor variant expects an AWT rendering thread if AWT is available. + * </p> + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #FPSAnimator(int, GLAutoDrawable, int, boolean) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ public FPSAnimator(final GLAutoDrawable drawable, final int fps, final boolean scheduleAtFixedRate) { - super(); + this(MODE_EXPECT_AWT_RENDERING_THREAD, drawable, fps, scheduleAtFixedRate); + } + + /** + * Creates an FPSAnimator with modeBits, see {@link AnimatorBase#AnimatorBase(int)}, a given target frames-per-second + * value, an initial drawable to animate, and a flag indicating + * whether to use fixed-rate scheduling. + * + * @param modeBits pass {@link AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD} if an AWT rendering thread is expected, otherwise {@code 0}. + * @param drawable {@link #add(GLAutoDrawable) added} {@link GLAutoDrawable} or {@code null} + * @param fps target frames per seconds + * @param scheduleAtFixedRate flag indicating fixed rate scheduling + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + * @see #FPSAnimator(int, GLAutoDrawable, int, boolean) + * @see GLProfile#isAWTAvailable() + * @see AnimatorBase#setModeBits(boolean, int) + */ + public FPSAnimator(final int modeBits, final GLAutoDrawable drawable, final int fps, final boolean scheduleAtFixedRate) { + super(modeBits); this.fps = fps; if (drawable != null) { add(drawable); |