From f10b30c16aeec428378d1d560d030b2d39801c4e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 11 Apr 2012 19:46:37 +0200 Subject: Refine GLMediaPlayer/TextureSequence, add MovieCube demo, fix minor bug in Texture - Add TextureSequence, base interface of GLMediaPlayer to genralize texture streams - TextureSequence / GLMediaPlayer: Use inner classes for event and texture data - getLastTexture() shall never return 'null', initialization of TextureSequence (initGLStream(..), etc) shall provide a TextureFrame w/ the stream's dimension. - GLMediaPlayerImpl.createTexImageImpl() y-flip defaults to 'false' impl. shall define y-flip, if required. - Added MovieCube demo - Fix Texture: initialize aspectRation for 'wrapping' ctor - --- .../jogamp/opengl/util/av/EGLMediaPlayerImpl.java | 9 ++-- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 62 +++++++++++----------- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 34 ++++++------ 3 files changed, 53 insertions(+), 52 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/util') diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index 2f6744fc5..52378d0fd 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package jogamp.opengl.av; +package jogamp.opengl.util.av; import java.nio.IntBuffer; @@ -33,6 +33,7 @@ import javax.media.opengl.GL; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLContext; @@ -53,7 +54,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { } } - public static class EGLTextureFrame extends TextureFrame { + public static class EGLTextureFrame extends TextureSequence.TextureFrame { public EGLTextureFrame(Texture t, long khrImage, long khrSync) { super(t); @@ -83,7 +84,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { } @Override - protected TextureFrame createTexImage(GL gl, int idx, int[] tex) { + protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) { final Texture texture = super.createTexImageImpl(gl, idx, tex, true); final long image; final long sync; @@ -123,7 +124,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { } @Override - protected void destroyTexImage(GL gl, TextureFrame imgTex) { + protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) { final EGLContext eglCtx = (EGLContext) gl.getContext(); final EGLExt eglExt = eglCtx.getEGLExt(); final EGLDrawable eglDrawable = (EGLDrawable) eglCtx.getGLDrawable(); diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index acd707288..bc3fa0919 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -25,7 +25,7 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ -package jogamp.opengl.av; +package jogamp.opengl.util.av; import java.io.IOException; import java.net.URLConnection; @@ -37,9 +37,9 @@ import javax.media.opengl.GL; import javax.media.opengl.GLES2; import javax.media.opengl.GLException; -import com.jogamp.opengl.av.GLMediaPlayer; -import com.jogamp.opengl.av.GLMediaEventListener; +import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureSequence; /** * After object creation an implementation may customize the behavior: @@ -86,8 +86,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected long frameNumber = 0; - protected TextureFrame[] texFrames = null; - protected HashMap texFrameMap = new HashMap(); + protected TextureSequence.TextureFrame[] texFrames = null; + protected HashMap texFrameMap = new HashMap(); private ArrayList eventListeners = new ArrayList(); protected GLMediaPlayerImpl() { @@ -172,27 +172,29 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } this.urlConn = urlConn; if (this.urlConn != null) { - try { - if(null!=texFrames) { - removeAllImageTextures(gl); - } else { - texFrames = new TextureFrame[textureCount]; - } - - final int[] tex = new int[textureCount]; - { - gl.glGenTextures(textureCount, tex, 0); - final int err = gl.glGetError(); - if( GL.GL_NO_ERROR != err ) { - throw new RuntimeException("TextureNames creation failed (num: "+textureCount+"): err "+toHexString(err)); + try { + if(null != gl) { + if(null!=texFrames) { + // re-init .. + removeAllImageTextures(gl); + } else { + texFrames = new TextureSequence.TextureFrame[textureCount]; + } + final int[] tex = new int[textureCount]; + { + gl.glGenTextures(textureCount, tex, 0); + final int err = gl.glGetError(); + if( GL.GL_NO_ERROR != err ) { + throw new RuntimeException("TextureNames creation failed (num: "+textureCount+"): err "+toHexString(err)); + } + } + initGLStreamImpl(gl, tex); + + for(int i=0; i pos_ms) { -- cgit v1.2.3