From 7ff2fcb36540aaed087e3a2ba2f0f84916bce2e2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Apr 2014 08:33:00 +0200 Subject: Add TextureSequence.isTextureAvailable(), allowing triggering action only when source becomes ready --- .../classes/com/jogamp/opengl/util/texture/TextureSequence.java | 6 ++++++ src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 5 +++++ .../jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java | 3 +++ 3 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index ab9d1f8f0..88f40e927 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -173,6 +173,12 @@ public interface TextureSequence { public int[] getTextureWrapST(); + /** + * Returns true if texture source is ready and a texture is available + * via {@link #getNextTexture(GL)} and {@link #getLastTexture()}. + */ + public boolean isTextureAvailable(); + /** * Returns the last updated texture. *

diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 6a0e0061f..63bb22d80 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -736,6 +736,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { frame.getTexture().destroy(gl); } + @Override + public final boolean isTextureAvailable() { + return State.Paused == state || State.Playing == state; + } + @Override public final TextureFrame getLastTexture() throws IllegalStateException { if( State.Paused != state && State.Playing != state ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java index b015aebba..7034f2c67 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java @@ -76,6 +76,9 @@ public class TextureSequenceDemo01 implements TextureSequence { return texWrapST; } + @Override + public boolean isTextureAvailable() { return true; } + @Override public TextureSequence.TextureFrame getLastTexture() throws IllegalStateException { return frame; // may return null -- cgit v1.2.3