summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/build-jogl.xml7
-rw-r--r--make/resources/android/AndroidManifest-test.xml10
-rw-r--r--make/resources/android/res-test/values/strings.xml2
-rwxr-xr-xmake/scripts/tests.sh6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaEventListener.java28
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java69
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java4
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java1
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java20
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java90
-rw-r--r--src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java26
-rw-r--r--src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java28
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java62
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java34
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java118
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java79
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java (renamed from src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java)6
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java2
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java89
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java436
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java164
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java130
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2.fp (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2.fp)2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2.vp (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2.vp)2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2_exttex.fp (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2_exttex.fp)2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_gl2.fp (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_gl2.fp)2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_gl2.vp (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_gl2.vp)2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_xxx.fp (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_xxx.fp)7
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_xxx.vp (renamed from src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_xxx.vp)0
34 files changed, 1188 insertions, 257 deletions
diff --git a/make/build-jogl.xml b/make/build-jogl.xml
index 9a4ad8b8e..b723c211b 100644
--- a/make/build-jogl.xml
+++ b/make/build-jogl.xml
@@ -150,7 +150,7 @@
value="com/jogamp/opengl/**/swt/**"/>
<property name="java.part.util"
- value="com/jogamp/opengl/util/* com/jogamp/opengl/util/texture/** com/jogamp/opengl/util/packrect/** jogamp/opengl/util/* jogamp/opengl/util/pngj/**"/>
+ value="com/jogamp/opengl/util/* com/jogamp/opengl/util/texture/** com/jogamp/opengl/util/av/* com/jogamp/opengl/util/packrect/** jogamp/opengl/util/* jogamp/opengl/util/av/* jogamp/opengl/util/pngj/**"/>
<property name="java.part.util.awt"
value="com/jogamp/opengl/util/**/awt/** com/jogamp/opengl/util/AWTAnimatorImpl*"/>
@@ -176,9 +176,6 @@
<property name="java.part.util.fixedfuncemu.shadercode"
value="jogamp/opengl/util/glsl/fixedfunc/shaders/* jogamp/opengl/util/glsl/fixedfunc/shaders/bin/**"/>
- <property name="java.part.util.av"
- value="com/jogamp/opengl/av/** jogamp/opengl/av/**"/>
-
<property name="java.part.nonjava"
value="${java.part.util.fixedfuncemu.shadercode} ${java.part.util.graph.shadercode} ${java.part.util.graph.fonts}"/>
@@ -1667,7 +1664,7 @@
</jar>
<jar manifest="${build.jogl}/manifest.mf" destfile="${jogl.util.jar}" filesonly="true">
<fileset dir="${classes}"
- includes="${java.part.util} ${java.part.util.glsl} ${java.part.util.graph} ${java.part.util.av}"
+ includes="${java.part.util} ${java.part.util.glsl} ${java.part.util.graph}"
excludes="${java.part.util.awt} ${java.part.util.gldesktop} ${java.part.util.fixedfuncemu}"/>
<fileset dir="resources/assets" includes="jogl/util/**" />
</jar>
diff --git a/make/resources/android/AndroidManifest-test.xml b/make/resources/android/AndroidManifest-test.xml
index c8779cda9..4e6a5a2ba 100644
--- a/make/resources/android/AndroidManifest-test.xml
+++ b/make/resources/android/AndroidManifest-test.xml
@@ -145,6 +145,16 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="com.jogamp.opengl.test.android.MovieCubeActivityLauncher0"
+ android:label="@string/activity_moviecube0_name"
+ android:description="@string/activity_moviecube_descr"
+ android:theme="@android:style/Theme.NoDisplay"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
</application>
</manifest>
diff --git a/make/resources/android/res-test/values/strings.xml b/make/resources/android/res-test/values/strings.xml
index 5f41a1be7..fcaf102ac 100644
--- a/make/resources/android/res-test/values/strings.xml
+++ b/make/resources/android/res-test/values/strings.xml
@@ -25,4 +25,6 @@
<string name="activity_moviesimple1b_name">MovieSimple1b</string>
<string name="activity_moviesimple2_name">MovieSimple2</string>
<string name="activity_moviesimple_descr">MovieSimple</string>
+ <string name="activity_moviecube0_name">MovieCube0</string>
+ <string name="activity_moviecube_descr">MovieCube</string>
</resources>
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 248663a96..c2081691c 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -62,6 +62,8 @@ function jrun() {
#D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState"
#D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL"
#D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode"
+ #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode"
+ #D_ARGS="-Djogl.debug.GLArrayData"
#D_ARGS="-Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable"
#D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen"
#D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true"
@@ -238,8 +240,10 @@ function testawtswt() {
#testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT
#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestGLReadBufferUtilTextureIOWrite01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestGLReadBufferUtilTextureIOWrite02NEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 $*
#
# awt (testawt)
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaEventListener.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaEventListener.java
deleted file mode 100644
index 9887a417c..000000000
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaEventListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-
-package com.jogamp.opengl.av;
-
-import javax.media.opengl.GL;
-
-public interface GLMediaEventListener {
-
- static final int EVENT_CHANGE_SIZE = 1<<0;
- static final int EVENT_CHANGE_FPS = 1<<1;
- static final int EVENT_CHANGE_BPS = 1<<2;
- static final int EVENT_CHANGE_LENGTH = 1<<3;
-
- /**
- * @param mp the event source
- * @param event_mask the changes attributes
- * @param when system time in msec.
- */
- public void attributesChanges(GLMediaPlayer mp, int event_mask, long when);
-
- /**
- * Signaling listeners that {@link GLMediaPlayer#getNextTexture(GL, boolean)} is able to deliver a new frame.
- * @param mp the event source
- * @param when system time in msec.
- **/
- public void newFrameAvailable(GLMediaPlayer mp, long when);
-
-}
-
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
index b3827d520..d86c8bfd0 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java
@@ -25,7 +25,7 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.av;
+package com.jogamp.opengl.util.av;
import java.io.IOException;
import java.net.URLConnection;
@@ -35,8 +35,7 @@ import javax.media.opengl.GLException;
import jogamp.opengl.Debug;
-import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.TextureSequence;
/**
* Lifecycle of an GLMediaPlayer:
@@ -49,8 +48,23 @@ import com.jogamp.opengl.util.texture.TextureCoords;
* <tr><td>{@link #destroy(GL)}</td> <td>ANY</td> <td>Uninitialized</td></tr>
* </table>
*/
-public interface GLMediaPlayer {
+public interface GLMediaPlayer extends TextureSequence {
public static final boolean DEBUG = Debug.debug("GLMediaPlayer");
+
+ public interface GLMediaEventListener extends TexSeqEventListener<GLMediaPlayer> {
+
+ static final int EVENT_CHANGE_SIZE = 1<<0;
+ static final int EVENT_CHANGE_FPS = 1<<1;
+ static final int EVENT_CHANGE_BPS = 1<<2;
+ static final int EVENT_CHANGE_LENGTH = 1<<3;
+
+ /**
+ * @param mp the event source
+ * @param event_mask the changes attributes
+ * @param when system time in msec.
+ */
+ public void attributesChanges(GLMediaPlayer mp, int event_mask, long when);
+ }
public enum State {
Uninitialized(0), Stopped(1), Playing(2), Paused(3);
@@ -62,38 +76,14 @@ public interface GLMediaPlayer {
}
}
- public static class TextureFrame {
- public TextureFrame(Texture t) {
- texture = t;
- // stMatrix = new float[4*4];
- // ProjectFloat.makeIdentityf(stMatrix, 0);
- }
-
- public final Texture getTexture() { return texture; }
- // public final float[] getSTMatrix() { return stMatrix; }
-
- public String toString() {
- return "TextureFrame[" + texture + "]";
- }
- protected final Texture texture;
- // protected final float[] stMatrix;
- }
-
public int getTextureCount();
- public int getTextureTarget();
-
/** Defaults to 0 */
public void setTextureUnit(int u);
- public int getTextureUnit();
-
/** Sets the texture min-mag filter, defaults to {@link GL#GL_NEAREST}. */
public void setTextureMinMagFilter(int[] minMagFilter);
- public int[] getTextureMinMagFilter();
-
/** Sets the texture min-mag filter, defaults to {@link GL#GL_CLAMP_TO_EDGE}. */
public void setTextureWrapST(int[] wrapST);
- public int[] getTextureWrapST();
/**
* Sets the stream to be used. Initializes all stream related states inclusive OpenGL ones,
@@ -157,27 +147,17 @@ public interface GLMediaPlayer {
public long seek(long msec);
/**
- * @return the last updated texture. Maybe <code>null</code> in case no last frame is available.
- * Not blocking.
+ * {@inheritDoc}
*/
- public TextureFrame getLastTexture();
-
+ public TextureSequence.TextureFrame getLastTexture();
+
/**
- * Returns the next texture to be rendered.
- * <p>
- * Implementation shall block until next frame is available if <code>blocking</code> is <code>true</code>,
- * otherwise it shall return the last frame in case a new frame is not available.
- * </p>
- * <p>
- * Shall return <code>null</code> in case <i>no</i> frame is available.
- * </p>
+ * {@inheritDoc}
*
* @see #addEventListener(GLMediaEventListener)
* @see GLMediaEventListener#newFrameAvailable(GLMediaPlayer, long)
*/
- public TextureFrame getNextTexture(GL gl, boolean blocking);
-
- public TextureCoords getTextureCoords();
+ public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking);
public URLConnection getURLConnection();
@@ -226,5 +206,6 @@ public interface GLMediaPlayer {
public void removeEventListener(GLMediaEventListener l);
- public GLMediaEventListener[] getEventListeners();
+ public GLMediaEventListener[] getEventListeners();
+
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java
index 1894f411f..df12fd12c 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java
@@ -25,9 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
-package com.jogamp.opengl.av;
+package com.jogamp.opengl.util.av;
-import jogamp.opengl.av.NullGLMediaPlayer;
+import jogamp.opengl.util.av.NullGLMediaPlayer;
import com.jogamp.common.os.AndroidVersion;
import com.jogamp.common.os.Platform;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
index 208fd053d..a94b1f827 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
@@ -197,6 +197,7 @@ public class Texture {
this.mustFlipVertically = mustFlipVertically;
this.texWidth = texWidth;
this.texHeight = texHeight;
+ aspectRatio = (float) imgWidth / (float) imgHeight;
setImageSize(imgWidth, imgHeight, target);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java
index 61f5d116c..39647039b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java
@@ -36,8 +36,6 @@
package com.jogamp.opengl.util.texture;
-import java.nio.FloatBuffer;
-
/** Specifies texture coordinates for a rectangular area of a
texture. Note that some textures are inherently flipped vertically
from OpenGL's standard coordinate system. This class takes care of
@@ -79,22 +77,6 @@ public class TextureCoords {
return d;
}
- /** Transfers <code>{s * ss, t * ts}</code> from this object into the given FloatBuffer in the following order:
- * <pre>
- * left, bottom
- * right, bottom
- * left, top
- * right top
- * </pre>
- */
- public FloatBuffer getST_LB_RB_LT_RT(FloatBuffer d, float ss, float ts) {
- d.put( left *ss); d.put( bottom*ts);
- d.put( right *ss); d.put( bottom*ts);
- d.put( left *ss); d.put( top *ts);
- d.put( right *ss); d.put( top *ts);
- return d;
- }
-
/** Returns the leftmost (x) texture coordinate of this
rectangle. */
public float left() { return left; }
@@ -110,4 +92,6 @@ public class TextureCoords {
/** Returns the topmost (y) texture coordinate of this
rectangle. */
public float top() { return top; }
+
+ public String toString() { return "TexCoord[h: "+left+" - "+right+", v: "+bottom+" - "+top+"]"; }
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java
new file mode 100644
index 000000000..e6d21c613
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java
@@ -0,0 +1,90 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.util.texture;
+
+import javax.media.opengl.GL;
+
+public interface TextureSequence {
+
+ public static class TextureFrame {
+ public TextureFrame(Texture t) {
+ texture = t;
+ // stMatrix = new float[4*4];
+ // ProjectFloat.makeIdentityf(stMatrix, 0);
+ }
+
+ public final Texture getTexture() { return texture; }
+ // public final float[] getSTMatrix() { return stMatrix; }
+
+ public String toString() {
+ return "TextureFrame[" + texture + "]";
+ }
+ protected final Texture texture;
+ // protected final float[] stMatrix;
+ }
+
+ public interface TexSeqEventListener<T extends TextureSequence> {
+ /**
+ * Signaling listeners that {@link TextureSequence#getNextTexture(GL, boolean)} is able to deliver a new frame.
+ * @param ts the event source
+ * @param when system time in msec.
+ **/
+ public void newFrameAvailable(T ts, long when);
+ }
+
+ public int getTextureTarget();
+
+ public int getTextureUnit();
+
+ public int[] getTextureMinMagFilter();
+
+ public int[] getTextureWrapST();
+
+ /**
+ * Returns the last updated texture.
+ * <p>
+ * In case the instance is just initialized, it shall return a <code>TextureFrame</code>
+ * object with valid attributes. The texture content may be undefined
+ * until the first call of {@link #getNextTexture(GL, boolean)}.<br>
+ * </p>
+ * Not blocking.
+ */
+ public TextureFrame getLastTexture();
+
+ /**
+ * Returns the next texture to be rendered.
+ * <p>
+ * Implementation shall block until next frame is available if <code>blocking</code> is <code>true</code>,
+ * otherwise it shall return the last frame in case a new frame is not available.
+ * </p>
+ * <p>
+ * Shall return <code>null</code> in case <i>no</i> frame is available.
+ * </p>
+ */
+ public TextureFrame getNextTexture(GL gl, boolean blocking);
+} \ No newline at end of file
diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
index ae45662db..a50f1507f 100644
--- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
+++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java
@@ -32,10 +32,10 @@ import java.io.IOException;
import javax.media.opengl.GL;
import javax.media.opengl.GLES2;
-import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.TextureSequence;
import jogamp.common.os.android.StaticContext;
-import jogamp.opengl.av.GLMediaPlayerImpl;
+import jogamp.opengl.util.av.GLMediaPlayerImpl;
import android.graphics.SurfaceTexture;
import android.graphics.SurfaceTexture.OnFrameAvailableListener;
@@ -51,7 +51,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
MediaPlayer mp;
volatile boolean updateSurface = false;
Object updateSurfaceLock = new Object();
- TextureFrame lastTexFrame = null;
+ TextureSequence.TextureFrame lastTexFrame = null;
/**
private static String toString(MediaPlayer m) {
@@ -133,12 +133,12 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
}
@Override
- public TextureFrame getLastTexture() {
+ public TextureSequence.TextureFrame getLastTexture() {
return lastTexFrame;
}
@Override
- public TextureFrame getNextTexture(GL gl, boolean blocking) {
+ public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) {
if(null != stex && null != mp) {
// Only block once, no while-loop.
// This relaxes locking code of non crucial resources/events.
@@ -166,11 +166,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
return lastTexFrame;
}
- @Override
- public TextureCoords getTextureCoords() {
- return texFrames[0].getTexture().getImageTexCoords();
- }
-
private void wakeUp(boolean newFrame) {
synchronized(updateSurfaceLock) {
if(newFrame) {
@@ -226,12 +221,19 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl {
totalFrames = 0;
duration = mp.getDuration();
acodec = "unknown";
- vcodec = "unknown";
+ vcodec = "unknown";
}
}
@Override
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ lastTexFrame = new TextureSequence.TextureFrame( createTexImageImpl(gl, idx, tex, true) );
+ // lastTexFrame = super.createTexImage(gl, idx, tex);
+ return lastTexFrame;
+ }
+
+ @Override
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
if(null != stex) {
stex.release();
stex = null;
diff --git a/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java
index 7c775dd9f..c005c2ea6 100644
--- a/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/omx/OMXGLMediaPlayer.java
@@ -7,11 +7,10 @@ import java.net.URL;
import javax.media.opengl.GL;
import javax.media.opengl.GLException;
-import com.jogamp.opengl.av.GLMediaEventListener;
-import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.TextureSequence;
-import jogamp.opengl.av.EGLMediaPlayerImpl;
import jogamp.opengl.egl.EGL;
+import jogamp.opengl.util.av.EGLMediaPlayerImpl;
public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
protected long moviePtr = 0;
@@ -26,7 +25,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
protected long o_totalFrames = 0;
protected long o_duration = 0;
- protected TextureFrame lastTex = null;
+ protected TextureSequence.TextureFrame lastTex = null;
public OMXGLMediaPlayer() {
super(TextureType.KHRImage, true);
@@ -41,7 +40,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
}
@Override
- protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
final EGLTextureFrame eglTex = (EGLTextureFrame) super.createTexImage(gl, idx, tex);
_setStreamEGLImageTexture2D(moviePtr, idx, tex[idx], eglTex.getImage(), eglTex.getSync());
lastTex = eglTex;
@@ -49,8 +48,9 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
}
@Override
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
- super.destroyTexImage(gl, imgTex);
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
+ lastTex = null;
+ super.destroyTexImage(gl, imgTex);
}
@Override
@@ -76,7 +76,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
System.out.println("setURL: p1 "+this);
_setStream(moviePtr, textureCount, path);
- System.out.println("setURL: p2 "+this);
+ System.out.println("setURL: p2 "+this);
}
@Override
@@ -135,18 +135,18 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
}
@Override
- public TextureFrame getLastTexture() {
+ public TextureSequence.TextureFrame getLastTexture() {
return lastTex;
}
@Override
- public synchronized TextureFrame getNextTexture(GL gl, boolean blocking) {
+ public synchronized TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) {
if(0==moviePtr) {
throw new GLException("OMX native instance null");
}
final int nextTex = _getNextTextureID(moviePtr, blocking);
if(0 < nextTex) {
- final TextureFrame eglImgTex = texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking)));
+ final TextureSequence.TextureFrame eglImgTex = texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking)));
if(null!=eglImgTex) {
lastTex = eglImgTex;
}
@@ -154,12 +154,6 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
return lastTex;
}
- @Override
- public TextureCoords getTextureCoords() {
- return lastTex.getTexture().getImageTexCoords();
- }
-
-
protected void attributesUpdated() {
int event_mask = 0;
if( o_width != width || o_height != height ) {
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<Integer, TextureFrame> texFrameMap = new HashMap<Integer, TextureFrame>();
+ protected TextureSequence.TextureFrame[] texFrames = null;
+ protected HashMap<Integer, TextureSequence.TextureFrame> texFrameMap = new HashMap<Integer, TextureSequence.TextureFrame>();
private ArrayList<GLMediaEventListener> eventListeners = new ArrayList<GLMediaEventListener>();
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<textureCount; i++) {
+ final TextureSequence.TextureFrame tf = createTexImage(gl, i, tex);
+ texFrames[i] = tf;
+ texFrameMap.put(tex[i], tf);
}
- }
- initGLStreamImpl(gl, tex);
-
- for(int i=0; i<textureCount; i++) {
- final TextureFrame tf = createTexImage(gl, i, tex);
- texFrames[i] = tf;
- texFrameMap.put(tex[i], tf);
}
state = State.Stopped;
return state;
@@ -216,9 +218,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
* @see #vcodec
*/
protected abstract void initGLStreamImpl(GL gl, int[] texNames) throws IOException;
-
- protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
- return new TextureFrame( createTexImageImpl(gl, idx, tex, true) );
+
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ return new TextureSequence.TextureFrame( createTexImageImpl(gl, idx, tex, false) );
}
protected Texture createTexImageImpl(GL gl, int idx, int[] tex, boolean mustFlipVertically) {
@@ -264,14 +266,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
mustFlipVertically);
}
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
imgTex.getTexture().destroy(gl);
}
protected void removeAllImageTextures(GL gl) {
if(null != texFrames) {
for(int i=0; i<textureCount; i++) {
- final TextureFrame imgTex = texFrames[i];
+ final TextureSequence.TextureFrame imgTex = texFrames[i];
if(null != imgTex) {
destroyTexImage(gl, imgTex);
texFrames[i] = null;
diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
index a5d41bc9c..c97f04225 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.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;
@@ -34,21 +34,21 @@ import java.nio.ByteBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GLProfile;
-import jogamp.opengl.av.GLMediaPlayerImpl;
+import jogamp.opengl.util.av.GLMediaPlayerImpl;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.IOUtil;
import com.jogamp.opengl.util.texture.Texture;
-import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureData;
import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.util.texture.TextureSequence;
/***
* A dummy null media player implementation using a static test frame (if available).
*/
public class NullGLMediaPlayer extends GLMediaPlayerImpl {
private TextureData texData = null;
- private TextureFrame frame = null;
+ private TextureSequence.TextureFrame frame = null;
private long pos_ms = 0;
private long pos_start = 0;
@@ -91,21 +91,16 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl {
}
@Override
- public TextureFrame getLastTexture() {
+ public TextureSequence.TextureFrame getLastTexture() {
return frame;
}
@Override
- public TextureFrame getNextTexture(GL gl, boolean blocking) {
+ public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) {
return frame;
}
@Override
- public TextureCoords getTextureCoords() {
- return frame.getTexture().getImageTexCoords();
- }
-
- @Override
public long getCurrentPosition() {
pos_ms = System.currentTimeMillis() - pos_start;
validatePos();
@@ -151,20 +146,23 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl {
}
@Override
- protected void destroyTexImage(GL gl, TextureFrame imgTex) {
- super.destroyTexImage(gl, imgTex);
- }
-
- @Override
- protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+ protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) {
Texture texture = super.createTexImageImpl(gl, idx, tex, false);
if(null != texData) {
texture.updateImage(gl, texData);
+ texData.destroy();
+ texData = null;
}
- frame = new TextureFrame( texture );
+ frame = new TextureSequence.TextureFrame( texture );
return frame;
}
+ @Override
+ protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) {
+ frame = null;
+ super.destroyTexImage(gl, imgTex);
+ }
+
private void validatePos() {
boolean considerPausing = false;
if( 0 > pos_ms) {
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java
new file mode 100644
index 000000000..4b84525f6
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java
@@ -0,0 +1,118 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.android;
+
+import java.io.IOException;
+import java.net.URLConnection;
+import java.util.Arrays;
+
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLProfile;
+
+import jogamp.newt.driver.android.AndroidWindow;
+import jogamp.newt.driver.android.NewtBaseActivity;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.newt.NewtFactory;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.opengl.GLWindow;
+
+import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube;
+import com.jogamp.opengl.util.Animator;
+
+import android.os.Bundle;
+import android.util.Log;
+
+public class MovieCubeActivity0 extends NewtBaseActivity {
+ static String TAG = "MovieCubeActivity0";
+
+ MouseAdapter toFrontMouseListener = new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ Object src = e.getSource();
+ if(src instanceof AndroidWindow) {
+ ((AndroidWindow)src).requestFocus(false);
+ }
+ } };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ String[] urls0 = new String[] {
+ System.getProperty("jnlp.media0_url2"),
+ System.getProperty("jnlp.media0_url1"),
+ System.getProperty("jnlp.media0_url0") };
+ final URLConnection urlConnection0 = getResource(urls0, 0);
+ if(null == urlConnection0) { throw new RuntimeException("no media reachable: "+Arrays.asList(urls0)); }
+
+ // also initializes JOGL
+ final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2());
+ capsMain.setBackgroundOpaque(false);
+
+ // screen for layout params ..
+ final com.jogamp.newt.Display dpy = NewtFactory.createDisplay(null);
+ final com.jogamp.newt.Screen scrn = NewtFactory.createScreen(dpy, 0);
+ scrn.addReference();
+
+ try {
+ final Animator animator = new Animator();
+ setAnimator(animator);
+
+ // Main
+ final MovieCube demoMain = new MovieCube(urlConnection0, -2.3f, 0f, 0f);
+ final GLWindow glWindowMain = GLWindow.create(scrn, capsMain);
+ glWindowMain.setFullscreen(true);
+ setContentView(getWindow(), glWindowMain);
+ glWindowMain.addGLEventListener(demoMain);
+ animator.add(glWindowMain);
+ glWindowMain.setVisible(true);
+
+ // animator.setUpdateFPSFrames(60, System.err);
+ animator.setUpdateFPSFrames(-1, null);
+ animator.resetFPSCounter();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ scrn.removeReference();
+
+ Log.d(TAG, "onCreate - X");
+ }
+
+ static URLConnection getResource(String path[], int off) {
+ URLConnection uc = null;
+ for(int i=off; null==uc && i<path.length; i++) {
+ if(null != path[i] && path[i].length()>0) {
+ uc = IOUtil.getResource(path[i], null);
+ Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uc));
+ }
+ }
+ return uc;
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java
new file mode 100644
index 000000000..0332906b7
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.android;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
+
+public class MovieCubeActivityLauncher0 extends LauncherUtil.BaseActivityLauncher {
+
+ static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0";
+ // static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" };
+ static String[] pkgs = new String[] { "com.jogamp.opengl.test" };
+
+ @Override
+ public void init() {
+ final OrderedProperties props = getProperties();
+ // props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v");
+ props.setProperty("jnlp.media0_url2", "");
+ props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4");
+ props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4");
+ props.setProperty("jnlp.media1_url0", "http://archive.org/download/ElephantsDream/ed_1024_512kb.mp4");
+ // props.setProperty("jogamp.debug.JNILibLoader", "true");
+ // props.setProperty("jogamp.debug.NativeLibrary", "true");
+ // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true");
+ // props.setProperty("jogamp.debug.IOUtil", "true");
+ // props.setProperty("nativewindow.debug", "all");
+ props.setProperty("nativewindow.debug.GraphicsConfiguration", "true");
+ // props.setProperty("jogl.debug", "all");
+ // props.setProperty("jogl.debug.GLProfile", "true");
+ props.setProperty("jogl.debug.GLDrawable", "true");
+ props.setProperty("jogl.debug.GLContext", "true");
+ props.setProperty("jogl.debug.GLSLCode", "true");
+ props.setProperty("jogl.debug.CapabilitiesChooser", "true");
+ // props.setProperty("jogl.debug.GLSLState", "true");
+ // props.setProperty("jogl.debug.DebugGL", "true");
+ // props.setProperty("jogl.debug.TraceGL", "true");
+ // props.setProperty("newt.debug", "all");
+ props.setProperty("newt.debug.Window", "true");
+ // props.setProperty("newt.debug.Window.MouseEvent", "true");
+ // props.setProperty("newt.debug.Window.KeyEvent", "true");
+ props.setProperty("jogamp.debug.IOUtil", "true");
+ }
+
+ @Override
+ public String getActivityName() {
+ return demo;
+ }
+ @Override
+ public List<String> getPackages() {
+ return Arrays.asList(pkgs);
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java
index 0698e421e..11babf187 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java
@@ -50,7 +50,7 @@ import android.os.Bundle;
import android.util.Log;
public class MovieSimpleActivity0 extends NewtBaseActivity {
- static String TAG = "NEWTGearsES2Activity";
+ static String TAG = "MovieSimpleActivity0";
MouseAdapter toFrontMouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
index 86b3ffb48..a5e5f4ccb 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java
@@ -45,16 +45,16 @@ import com.jogamp.newt.event.MouseAdapter;
import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
-import com.jogamp.opengl.av.GLMediaPlayer;
import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple;
import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.av.GLMediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
-public class MovieSimpleActivity extends NewtBaseActivity {
- static String TAG = "NEWTGearsES2Activity";
+public class MovieSimpleActivity1 extends NewtBaseActivity {
+ static String TAG = "MovieSimpleActivity1";
MouseAdapter toFrontMouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java
index a5370e90b..e3c87bd7a 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java
@@ -34,7 +34,7 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
public class MovieSimpleActivityLauncher00b extends LauncherUtil.BaseActivityLauncher {
- static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity";
+ static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity1";
// static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" };
static String[] pkgs = new String[] { "com.jogamp.opengl.test" };
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
index ff3fadadf..5fcb9d584 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
@@ -34,7 +34,7 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
public class MovieSimpleActivityLauncher01a extends LauncherUtil.BaseActivityLauncher {
- static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity";
+ static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity1";
// static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" };
static String[] pkgs = new String[] { "com.jogamp.opengl.test" };
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java
index 9992ac65a..2801acf48 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java
@@ -34,7 +34,7 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
public class MovieSimpleActivityLauncher01b extends LauncherUtil.BaseActivityLauncher {
- static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity";
+ static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity1";
// static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" };
static String[] pkgs = new String[] { "com.jogamp.opengl.test" };
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
index 082cc6335..f862b5ee9 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
@@ -34,7 +34,7 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
public class MovieSimpleActivityLauncher02 extends LauncherUtil.BaseActivityLauncher {
- static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity";
+ static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity1";
// static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" };
static String[] pkgs = new String[] { "com.jogamp.opengl.test" };
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java
new file mode 100644
index 000000000..5e607feb3
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java
@@ -0,0 +1,89 @@
+package com.jogamp.opengl.test.junit.jogl.demos;
+
+import java.net.URLConnection;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.opengl.util.av.NullGLMediaPlayer;
+
+import com.jogamp.common.util.IOUtil;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureData;
+import com.jogamp.opengl.util.texture.TextureIO;
+import com.jogamp.opengl.util.texture.TextureSequence;
+
+public class TestTextureSequence implements TextureSequence {
+ TextureSequence.TextureFrame frame = null;
+ int textureUnit = 0;
+ protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST };
+ protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE };
+
+ public TestTextureSequence() {
+ }
+
+ public void initGLResources(GL gl) throws GLException {
+ if(null == frame) {
+ TextureData texData = null;
+ try {
+ URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader());
+ if(null != urlConn) {
+ texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ final Texture tex = new Texture(gl, texData);
+ frame = new TextureSequence.TextureFrame(tex);
+ tex.bind(gl);
+ gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]);
+ gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]);
+ gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_S, texWrapST[0]);
+ gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_T, texWrapST[1]);
+ }
+ }
+
+ public void destroyGLResources(GL gl) {
+ if(null != frame) {
+ frame.getTexture().destroy(gl);
+ frame = null;
+ }
+ }
+
+ public void destroy(GL gl) throws GLException {
+ frame.getTexture().destroy(gl);
+ frame = null;
+ }
+
+ @Override
+ public int getTextureTarget() {
+ return frame.getTexture().getTarget();
+ }
+
+ @Override
+ public int getTextureUnit() {
+ return textureUnit;
+ }
+
+ @Override
+ public int[] getTextureMinMagFilter() {
+ return texMinMagFilter;
+ }
+
+ @Override
+ public int[] getTextureWrapST() {
+ return texWrapST;
+ }
+
+ @Override
+ public TextureSequence.TextureFrame getLastTexture() {
+ return frame; // may return null
+ }
+
+ @Override
+ public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) {
+ return frame;
+ }
+
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java
new file mode 100644
index 000000000..f330dde0d
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java
@@ -0,0 +1,436 @@
+package com.jogamp.opengl.test.junit.jogl.demos.es2;
+
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLES2;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+import javax.media.opengl.GLUniformData;
+import javax.media.opengl.fixedfunc.GLMatrixFunc;
+
+import com.jogamp.newt.Window;
+import com.jogamp.newt.event.MouseAdapter;
+import com.jogamp.newt.event.MouseEvent;
+import com.jogamp.newt.event.MouseListener;
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.test.junit.jogl.demos.TestTextureSequence;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.GLArrayDataServer;
+import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderCode;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
+import com.jogamp.opengl.util.glsl.ShaderState;
+import com.jogamp.opengl.util.texture.Texture;
+import com.jogamp.opengl.util.texture.TextureSequence;
+
+public class TexCubeES2 implements GLEventListener {
+ public TexCubeES2 (TextureSequence texSource, boolean innerCube, float zoom0, float rotx, float roty) {
+ this.texSource = texSource;
+ this.innerCube = innerCube;
+ this.zoom0 = zoom0;
+ this.view_rotx = rotx;
+ this.view_roty = roty;
+ }
+
+ private TextureSequence texSource;
+ private ShaderState st;
+ private PMVMatrix pmvMatrix;
+ private GLUniformData pmvMatrixUniform;
+ // private TextureCoords[] textureCoords = null;
+ private float nearPlaneNormalized;
+ // private float zoom0=-5.0f, zoom=zoom0;
+ // private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f;
+ private float zoom0=-2.3f, zoom=zoom0;
+ private float view_rotx = 0.0f, view_roty = 0.0f, view_rotz = 0.0f;
+ int[] vboNames = new int[4];
+ boolean innerCube;
+ boolean initialized = false;
+ private ByteBuffer cubeIndices;
+
+ private final MouseListener mouseAction = new MouseAdapter() {
+ int lx = 0;
+ int ly = 0;
+ boolean first = false;
+
+ public void mousePressed(MouseEvent e) {
+ first = true;
+ }
+ public void mouseMoved(MouseEvent e) {
+ first = false;
+ }
+ public void mouseDragged(MouseEvent e) {
+ int width, height;
+ Object source = e.getSource();
+ Window window = null;
+ if(source instanceof Window) {
+ window = (Window) source;
+ width=window.getWidth();
+ height=window.getHeight();
+ } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
+ java.awt.Component comp = (java.awt.Component) source;
+ width=comp.getWidth();
+ height=comp.getHeight();
+ } else {
+ throw new RuntimeException("Event source neither Window nor Component: "+source);
+ }
+ if(e.getPointerCount()==2) {
+ // 2 pointers zoom ..
+ if(first) {
+ lx = Math.abs(e.getY(0)-e.getY(1));
+ first=false;
+ return;
+ }
+ int nv = Math.abs(e.getY(0)-e.getY(1));
+ int dy = nv - lx;
+
+ zoom += 40f*Math.signum(dy)/(float)height;
+
+ lx = nv;
+ } else {
+ // 1 pointer rotate
+ if(first) {
+ lx = e.getX();
+ ly = e.getY();
+ first=false;
+ return;
+ }
+ int nx = e.getX();
+ int ny = e.getY();
+ view_roty += 360f * ( (float)( nx - lx ) / (float)width );
+ view_rotx += 360f * ( (float)( ny - ly ) / (float)height );
+ lx = nx;
+ ly = ny;
+ }
+ }
+ public void mouseWheelMoved(MouseEvent e) {
+ zoom += e.getWheelRotation()/10f;
+ System.err.println("zoom: "+zoom);
+ }
+ };
+
+
+ private void initShader(GL2ES2 gl, boolean useExternalTexture) {
+ // Create & Compile the shader objects
+ final String vShaderBasename = gl.isGLES2() ? "texsimple_es2" : "texsimple_gl2" ;
+ final String fShaderBasename = gl.isGLES2() ? ( useExternalTexture ? "texsimple_es2_exttex" : "texsimple_es2" ) : "texsimple_gl2";
+
+ ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, TexCubeES2.class,
+ "shader", "shader/bin", vShaderBasename);
+ ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, TexCubeES2.class,
+ "shader", "shader/bin", fShaderBasename);
+
+ // Create & Link the shader program
+ ShaderProgram sp = new ShaderProgram();
+ sp.add(rsVp);
+ sp.add(rsFp);
+ if(!sp.link(gl, System.err)) {
+ throw new GLException("Couldn't link program: "+sp);
+ }
+
+ // Let's manage all our states using ShaderState.
+ st = new ShaderState();
+ st.attachShaderProgram(gl, sp, false);
+ }
+
+ GLArrayDataServer interleavedVBO;
+
+ public void init(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ System.err.println(JoglVersion.getGLInfo(gl, null));
+
+ final boolean useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == texSource.getTextureTarget();
+ if(useExternalTexture && !gl.isExtensionAvailable("GL_OES_EGL_image_external")) {
+ throw new GLException("GL_OES_EGL_image_external requested but not available");
+ }
+
+ initShader(gl, useExternalTexture);
+
+ // Push the 1st uniform down the path
+ st.useProgram(gl, true);
+
+ pmvMatrix = new PMVMatrix();
+ reshapePMV(drawable.getWidth(), drawable.getHeight());
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ if(!st.uniform(gl, pmvMatrixUniform)) {
+ throw new GLException("Error setting PMVMatrix in shader: "+st);
+ }
+ if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", texSource.getTextureUnit()))) {
+ throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
+ }
+
+
+ {
+ final Texture tex= texSource.getLastTexture().getTexture();
+ final float aspect = tex.getAspectRatio();
+ System.err.println("XXX0: aspect: "+aspect);
+ System.err.println("XXX0: y-flip: "+tex.getMustFlipVertically());
+ System.err.println("XXX0: "+tex.getImageTexCoords());
+ final float ss=1f, ts=aspect; // scale tex-coord
+ final float dy = ( 1f - aspect ) / 2f ;
+ for(int i=0; i<s_cubeTexCoords.length; i+=2) {
+ s_cubeTexCoords[i+0] *= ss;
+ final float t = s_cubeTexCoords[i+1];
+ if(t==0 && !tex.getMustFlipVertically() || t!=0 && tex.getMustFlipVertically()) {
+ s_cubeTexCoords[i+1] = 0f + dy;
+ } else {
+ s_cubeTexCoords[i+1] = 1f * ts + dy;
+ }
+ }
+ }
+
+
+ interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*6*4, GL.GL_STATIC_DRAW);
+ {
+ interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
+ //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
+
+ FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
+
+ for(int i=0; i<6*4; i++) {
+ ib.put(s_cubeVertices, i*3, 3);
+ ib.put(s_cubeColors, i*4, 4);
+ //ib.put(s_cubeNormals, i*3, 3);
+ ib.put(s_cubeTexCoords, i*2, 2);
+ }
+ }
+ interleavedVBO.seal(gl, true);
+ interleavedVBO.enableBuffer(gl, false);
+ st.ownAttribute(interleavedVBO, true);
+ cubeIndices = ByteBuffer.wrap(s_cubeIndices);
+
+ gl.glEnable(GL2ES2.GL_DEPTH_TEST);
+
+ st.useProgram(gl, false);
+
+ if (drawable instanceof Window) {
+ Window window = (Window) drawable;
+ window.addMouseListener(mouseAction);
+ }
+
+ // Let's show the completed shader state ..
+ System.out.println("iVBO: "+interleavedVBO);
+ System.out.println(st);
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glViewport(0, 0, width, height);
+
+ if(innerCube) {
+ // Clear background to white
+ gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f);
+ } else {
+ // Clear background to blue
+ gl.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
+ }
+
+ if(!innerCube) {
+ // lights on
+ } else {
+ // lights off
+ }
+ // gl.glEnable(GL.GL_CULL_FACE);
+ // gl.glDisable(GL.GL_DITHER);
+
+ if(null != st) {
+ reshapePMV(width, height);
+ st.useProgram(gl, true);
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+ }
+ }
+
+
+ private void reshapePMV(int width, int height) {
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
+ pmvMatrix.glLoadIdentity();
+ if(!innerCube) {
+ pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1f, 10.0f);
+ nearPlaneNormalized = 1f/(100f-1f);
+ } else {
+ pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 10.0f);
+ nearPlaneNormalized = 0f;
+ }
+ System.err.println("XXX0: Perspective nearPlaneNormalized: "+nearPlaneNormalized);
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, zoom0);
+ }
+
+
+ public void dispose(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ texSource = null;
+ pmvMatrixUniform = null;
+ pmvMatrix.destroy();
+ pmvMatrix=null;
+ st.destroy(gl);
+ st=null;
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ st.useProgram(gl, true);
+
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, zoom);
+ pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f);
+ pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f);
+ pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f);
+ st.uniform(gl, pmvMatrixUniform);
+ interleavedVBO.enableBuffer(gl, true);
+ Texture tex = null;
+ if(null!=texSource) {
+ final TextureSequence.TextureFrame texFrame = texSource.getNextTexture(gl, true);
+ if(null != texFrame) {
+ tex = texFrame.getTexture();
+ gl.glActiveTexture(GL.GL_TEXTURE0+texSource.getTextureUnit());
+ tex.enable(gl);
+ tex.bind(gl);
+ }
+ }
+ gl.glDrawElements(GL.GL_TRIANGLES, 6 * 6, GL.GL_UNSIGNED_BYTE, cubeIndices);
+ if(null != tex) {
+ tex.disable(gl);
+ }
+ interleavedVBO.enableBuffer(gl, false);
+ st.useProgram(gl, false);
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ static final float[] light_position = { -50.f, 50.f, 50.f, 0.f };
+ static final float[] light_ambient = { 0.125f, 0.125f, 0.125f, 1.f };
+ static final float[] light_diffuse = { 1.0f, 1.0f, 1.0f, 1.f };
+ static final float[] material_spec = { 1.0f, 1.0f, 1.0f, 0.f };
+ static final float[] zero_vec4 = { 0.0f, 0.0f, 0.0f, 0.f };
+
+ private static final float[] s_cubeVertices = /* f b t b r l */
+ {
+ -1f, 1f, 1f, 1f, -1f, 1f, 1f, 1f, 1f, -1f, -1f, 1f,
+
+ -1f, 1f, -1f, 1f, -1f, -1f, 1f, 1f, -1f, -1f, -1f, -1f,
+
+ -1f, -1f, 1f, 1f, -1f, -1f, 1f, -1f, 1f, -1f, -1f, -1f,
+
+ -1f, 1f, 1f, 1f, 1f, -1f, 1f, 1f, 1f, -1f, 1f, -1f,
+
+ 1f, -1f, 1f, 1f, 1f, -1f, 1f, 1f, 1f, 1f, -1f, -1f,
+
+ -1f, -1f, 1f, -1f, 1f, -1f, -1f, 1f, 1f, -1f, -1f, -1f
+ };
+
+ private static final float[] s_cubeTexCoords =
+ { // LT RB RT LB
+ 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
+
+ 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
+
+ 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
+
+ 0f, 1f, 1f, 0f, 1f, 1f, 0f, 0f,
+
+ 0f, 0f, 1f, 1f, 0f, 1f, 1f, 0f,
+
+ 0f, 0f, 1f, 1f, 0f, 1f, 1f, 0f,
+ };
+
+ private static final float[] s_cubeColors =
+ {
+ 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f,
+
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+ 40f/255f, 80f/255f, 160f/255f, 255f/255f, 40f/255f, 80f/255f, 160f/255f, 255f/255f,
+
+ 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
+ 128f/255f, 128f/255f, 128f/255f, 255f/255f, 128f/255f, 128f/255f, 128f/255f, 255f/255f,
+
+ 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f,
+ 255f/255f, 110f/255f, 10f/255f, 255f/255f, 255f/255f, 110f/255f, 10f/255f, 255f/255f,
+
+ 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f,
+ 255f/255f, 70f/255f, 60f/255f, 255f/255f, 255f/255f, 70f/255f, 60f/255f, 255f/255f
+ };
+
+ private static final float[] s_cubeNormals =
+ {
+ 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f,
+
+ 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f,
+
+ 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f,
+
+ 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f,
+
+ 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f, 1f, 0f, 0f,
+
+ -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f, -1f, 0f, 0f
+ };
+ private static final byte[] s_cubeIndices =
+ {
+ 0, 3, 1, 2, 0, 1, /* front */
+ 6, 5, 4, 5, 7, 4, /* back */
+ 8, 11, 9, 10, 8, 9, /* top */
+ 15, 12, 13, 12, 14, 13, /* bottom */
+ 16, 19, 17, 18, 16, 17, /* right */
+ 23, 20, 21, 20, 22, 21 /* left */
+ };
+
+ public static void main(String[] args) {
+ int width = 510;
+ int height = 300;
+ System.err.println("TexCubeES2.run()");
+
+ final GLWindow window = GLWindow.create(new GLCapabilities(GLProfile.getGL2ES2()));
+ // Size OpenGL to Video Surface
+ window.setSize(width, height);
+ window.setFullscreen(false);
+ window.setSize(width, height);
+ final TestTextureSequence texSource = new TestTextureSequence();
+ window.addGLEventListener(new GLEventListener() {
+ @Override
+ public void init(GLAutoDrawable drawable) {
+ texSource.initGLResources(drawable.getGL());
+ }
+ @Override
+ public void dispose(GLAutoDrawable drawable) { }
+ @Override
+ public void display(GLAutoDrawable drawable) { }
+ @Override
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ });
+ window.addGLEventListener(new TexCubeES2(texSource, false, -2.3f, 0f, 0f));
+ window.setVisible(true);
+ final Animator anim = new Animator(window);
+ // anim.setUpdateFPSFrames(60, System.err);
+ anim.start();
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ anim.stop();
+ }
+ });
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
new file mode 100755
index 000000000..343c4b2a6
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+
+package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.media.opengl.GL2ES2;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLEventListener;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import com.jogamp.newt.event.WindowAdapter;
+import com.jogamp.newt.event.WindowEvent;
+import com.jogamp.newt.opengl.GLWindow;
+import com.jogamp.opengl.JoglVersion;
+import com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2;
+import com.jogamp.opengl.test.junit.util.MiscUtils;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.av.GLMediaPlayer;
+import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
+import com.jogamp.opengl.util.av.GLMediaPlayerFactory;
+
+public class MovieCube implements GLEventListener, GLMediaEventListener {
+ GLWindow window;
+ boolean quit = false;
+ TexCubeES2 cube=null;
+ GLMediaPlayer mPlayer=null;
+ URLConnection stream = null;
+
+ public MovieCube(URLConnection stream, float zoom0, float rotx, float roty) throws IOException {
+ this.stream = stream;
+ mPlayer = GLMediaPlayerFactory.create();
+ mPlayer.addEventListener(this);
+ cube = new TexCubeES2(mPlayer, false, zoom0, rotx, roty);
+ }
+
+ @Override
+ public void attributesChanges(GLMediaPlayer mp, int event_mask, long when) {
+ System.out.println("attributesChanges: "+mp+", 0x"+Integer.toHexString(event_mask)+", when "+when);
+ }
+
+ @Override
+ public void newFrameAvailable(GLMediaPlayer mp, long when) {
+ // System.out.println("newFrameAvailable: "+mp+", when "+when);
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ System.err.println(JoglVersion.getGLInfo(gl, null));
+
+ try {
+ System.out.println("p0 "+mPlayer);
+ mPlayer.initGLStream(gl, stream);
+ System.out.println("p1 "+mPlayer);
+ } catch (Exception e) {
+ e.printStackTrace();
+ if(null != mPlayer) {
+ mPlayer.destroy(gl);
+ mPlayer = null;
+ }
+ throw new GLException(e);
+ }
+
+ cube.init(drawable);
+ mPlayer.start();
+ }
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ if(null == mPlayer) { return; }
+ cube.reshape(drawable, x, y, width, height);
+ }
+
+ public void dispose(GLAutoDrawable drawable) {
+ if(null == mPlayer) { return; }
+ mPlayer.stop();
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ mPlayer.destroy(gl);
+ mPlayer=null;
+ cube.dispose(drawable);
+ cube=null;
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ if(null == mPlayer) { return; }
+ cube.display(drawable);
+ }
+
+ public void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ public static void main(String[] args) throws MalformedURLException, IOException {
+ int width = 510;
+ int height = 300;
+ System.err.println("TexCubeES2.run()");
+
+ String url_s="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4";
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-width")) {
+ i++;
+ width = MiscUtils.atoi(args[i], width);
+ } else if(args[i].equals("-height")) {
+ i++;
+ height = MiscUtils.atoi(args[i], height);
+ } else if(args[i].equals("-url")) {
+ i++;
+ url_s = args[i];
+ }
+ }
+ final MovieCube mc = new MovieCube(new URL(url_s).openConnection(), -2.3f, 0f, 0f);
+
+ final GLWindow window = GLWindow.create(new GLCapabilities(GLProfile.getGL2ES2()));
+ // Size OpenGL to Video Surface
+ window.setSize(width, height);
+ window.setFullscreen(false);
+ window.setSize(width, height);
+ window.addGLEventListener(mc);
+ window.setVisible(true);
+ final Animator anim = new Animator(window);
+ // anim.setUpdateFPSFrames(60, System.err);
+ anim.start();
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ anim.stop();
+ }
+ });
+ }
+}
+
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
index d32283473..fa2870437 100755
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
@@ -36,7 +36,6 @@ import java.nio.FloatBuffer;
import javax.media.opengl.GL;
import javax.media.opengl.GL2ES2;
-import javax.media.opengl.GLArrayData;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLES2;
@@ -54,18 +53,19 @@ import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.JoglVersion;
-import com.jogamp.opengl.av.GLMediaPlayer;
-import com.jogamp.opengl.av.GLMediaEventListener;
-import com.jogamp.opengl.av.GLMediaPlayerFactory;
import com.jogamp.opengl.test.junit.util.MiscUtils;
import com.jogamp.opengl.util.Animator;
import com.jogamp.opengl.util.GLArrayDataServer;
import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.av.GLMediaPlayer;
+import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
+import com.jogamp.opengl.util.av.GLMediaPlayerFactory;
import com.jogamp.opengl.util.glsl.ShaderCode;
import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.glsl.ShaderState;
import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
+import com.jogamp.opengl.util.texture.TextureSequence;
public class MovieSimple implements GLEventListener, GLMediaEventListener {
private int winWidth, winHeight;
@@ -93,8 +93,15 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
public void setTransparency(float alpha) {
this.effects |= EFFECT_TRANSPARENT;
this.alpha = alpha;
- }
-
+ }
+
+ GLMediaPlayer mPlayer;
+ URLConnection stream = null;
+ boolean mPlayerExternal;
+ boolean mPlayerShared;
+ boolean mPlayerScaleOrig;
+ GLArrayDataServer interleavedVBO;
+
private final MouseListener mouseAction = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if(e.getY()<=winHeight/2 && null!=mPlayer && 1 == e.getClickCount()) {
@@ -133,22 +140,11 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
// prevMouseY = y;
}
public void mouseWheelMoved(MouseEvent e) {
- int r = e.getWheelRotation();
- if(r>0) {
- zoom += 0.1;
- } else if(r<0) {
- zoom -= 0.1;
- }
+ zoom += e.getWheelRotation()/10f;
System.err.println("zoom: "+zoom);
}
};
-
- GLMediaPlayer mPlayer;
- URLConnection stream = null;
- boolean mPlayerExternal;
- boolean mPlayerShared;
- boolean mPlayerScaleOrig;
-
+
public MovieSimple(URLConnection stream) throws IOException {
mPlayerScaleOrig = false;
mPlayerShared = false;
@@ -182,7 +178,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
@Override
public void newFrameAvailable(GLMediaPlayer mp, long when) {
- // System.out.println("newFrameAvailable: "+mp+", when "+when);
+ // System.out.println("newFrameAvailable: "+mp+", when "+when);
}
public void start() {
@@ -205,8 +201,8 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
private void initShader(GL2ES2 gl, boolean useExternalTexture) {
// Create & Compile the shader objects
- final String vShaderBasename = gl.isGLES2() ? "moviesimple_es2" : "moviesimple_gl2" ;
- final String fShaderBasename = gl.isGLES2() ? ( useExternalTexture ? "moviesimple_es2_exttex" : "moviesimple_es2" ) : "moviesimple_gl2";
+ final String vShaderBasename = gl.isGLES2() ? "texsimple_es2" : "texsimple_gl2" ;
+ final String fShaderBasename = gl.isGLES2() ? ( useExternalTexture ? "texsimple_es2_exttex" : "texsimple_es2" ) : "texsimple_gl2";
ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, MovieSimple.class,
"../shader", "../shader/bin", vShaderBasename);
@@ -236,8 +232,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
System.err.println("Alpha: "+alpha+", opaque "+drawable.getChosenGLCapabilities().isBackgroundOpaque()+
", "+drawable.getClass().getName()+", "+drawable);
- gl.glFinish();
-
boolean useExternalTexture = false;
try {
System.out.println("p0 "+mPlayer+", shared "+mPlayerShared);
@@ -281,6 +275,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
float mWidth = mPlayer.getWidth();
float mHeight = mPlayer.getHeight();
float mAspect = mWidth/mHeight;
+ System.err.println("XXX0: mov aspect: "+mAspect);
float[] verts;
float xs, ys;
if(orthoProjection) {
@@ -311,56 +306,59 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
}
final float ss = 1f, ts = 1f; // scale tex-coord
- final GLArrayDataServer interleaved = GLArrayDataServer.createGLSLInterleaved(9, GL.GL_FLOAT, false, 12, GL.GL_STATIC_DRAW);
+ interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
{
- GLArrayData vertices = interleaved.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
- FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer();
+ interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
+ interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
- GLArrayData texcoord = interleaved.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
- TextureCoords tc = mPlayer.getTextureCoords();
- FloatBuffer texcoordb = (FloatBuffer)texcoord.getBuffer();
+ final FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer();
+ final Texture tex= mPlayer.getLastTexture().getTexture();
+ final TextureCoords tc = tex.getImageTexCoords();
+ final float aspect = tex.getAspectRatio();
+ System.err.println("XXX0: tex aspect: "+aspect);
+ System.err.println("XXX0: tex y-flip: "+tex.getMustFlipVertically());
+ System.err.println("XXX0: "+tex.getImageTexCoords());
- GLArrayData colors = interleaved.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
- FloatBuffer colorb = (FloatBuffer)colors.getBuffer();
-
// left-bottom
- verticeb.put(verts[0]); verticeb.put(verts[1]); verticeb.put(verts[2]);
- texcoordb.put( tc.left() *ss); texcoordb.put( tc.bottom() *ts);
+ ib.put(verts[0]); ib.put(verts[1]); ib.put(verts[2]);
if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
- colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put(alpha);
+ ib.put( 0); ib.put( 0); ib.put( 0); ib.put(alpha);
} else {
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
}
+ ib.put( tc.left() *ss); ib.put( tc.bottom() *ts);
// right-bottom
- verticeb.put(verts[3]); verticeb.put(verts[1]); verticeb.put(verts[2]);
- texcoordb.put( tc.right() *ss); texcoordb.put( tc.bottom() *ts);
+ ib.put(verts[3]); ib.put(verts[1]); ib.put(verts[2]);
if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
- colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put(alpha);
+ ib.put( 0); ib.put( 0); ib.put( 0); ib.put(alpha);
} else {
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
}
+ ib.put( tc.right() *ss); ib.put( tc.bottom() *ts);
// left-top
- verticeb.put(verts[0]); verticeb.put(verts[4]); verticeb.put(verts[2]);
- texcoordb.put( tc.left() *ss); texcoordb.put( tc.top() *ts);
+ ib.put(verts[0]); ib.put(verts[4]); ib.put(verts[2]);
if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
} else {
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
}
+ ib.put( tc.left() *ss); ib.put( tc.top() *ts);
// right-top
- verticeb.put(verts[3]); verticeb.put(verts[4]); verticeb.put(verts[2]);
- texcoordb.put( tc.right() *ss); texcoordb.put( tc.top() *ts);
+ ib.put(verts[3]); ib.put(verts[4]); ib.put(verts[2]);
if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
} else {
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
}
+ ib.put( tc.right() *ss); ib.put( tc.top() *ts);
}
- interleaved.seal(gl, true);
-
+ interleavedVBO.seal(gl, true);
+ interleavedVBO.enableBuffer(gl, false);
+ st.ownAttribute(interleavedVBO, true);
gl.glClearColor(0.3f, 0.3f, 0.3f, 0.3f);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
@@ -368,6 +366,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
st.useProgram(gl, false);
// Let's show the completed shader state ..
+ System.out.println("iVBO: "+interleavedVBO);
System.out.println(st);
if(null!=mPlayer) {
@@ -460,24 +459,27 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
rotate = 0;
}
st.uniform(gl, pmvMatrixUniform);
-
+ interleavedVBO.enableBuffer(gl, true);
+ Texture tex = null;
if(null!=mPlayer) {
- final GLMediaPlayer.TextureFrame texFrame;
+ final TextureSequence.TextureFrame texFrame;
if(mPlayerShared) {
texFrame=mPlayer.getLastTexture();
} else {
texFrame=mPlayer.getNextTexture(gl, true);
}
if(null != texFrame) {
- final Texture tex = texFrame.getTexture();
+ tex = texFrame.getTexture();
gl.glActiveTexture(GL.GL_TEXTURE0+mPlayer.getTextureUnit());
tex.enable(gl);
tex.bind(gl);
- gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
- tex.disable(gl);
}
}
-
+ gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
+ if(null != tex) {
+ tex.disable(gl);
+ }
+ interleavedVBO.enableBuffer(gl, false);
st.useProgram(gl, false);
}
@@ -485,19 +487,19 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
}
public static void main(String[] args) throws IOException, MalformedURLException {
- int w = 640;
- int h = 480;
+ int width = 640;
+ int height = 600;
boolean ortho = true;
boolean zoom = false;
- String url_s="file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4";
+ String url_s="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4";
for(int i=0; i<args.length; i++) {
if(args[i].equals("-width")) {
i++;
- w = MiscUtils.atoi(args[i], w);
+ width = MiscUtils.atoi(args[i], width);
} else if(args[i].equals("-height")) {
i++;
- h = MiscUtils.atoi(args[i], h);
+ height = MiscUtils.atoi(args[i], height);
} else if(args[i].equals("-projection")) {
ortho=false;
} else if(args[i].equals("-zoom")) {
@@ -507,7 +509,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
url_s = args[i];
}
}
- MovieSimple ms = new MovieSimple(new URL(url_s).openConnection());
+ final MovieSimple ms = new MovieSimple(new URL(url_s).openConnection());
ms.setScaleOrig(!zoom);
ms.setOrthoProjection(ortho);
@@ -517,7 +519,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
window.addGLEventListener(ms);
- window.setSize(w, h);
+ window.setSize(width, height);
window.setVisible(true);
final Animator anim = new Animator(window);
anim.start();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2.fp
index e3b9eea04..3a7dcf7a2 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2.fp
@@ -6,4 +6,4 @@ precision mediump float;
uniform sampler2D mgl_ActiveTexture;
-#include moviesimple_xxx.fp
+#include texsimple_xxx.fp
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2.vp
index 6708d546e..16c070a31 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2.vp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2.vp
@@ -4,4 +4,4 @@
precision mediump float;
-#include moviesimple_xxx.vp \ No newline at end of file
+#include texsimple_xxx.vp
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2_exttex.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2_exttex.fp
index 39b0fe8d0..c45cebaf3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_es2_exttex.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_es2_exttex.fp
@@ -8,4 +8,4 @@ precision mediump float;
uniform samplerExternalOES mgl_ActiveTexture;
-#include moviesimple_xxx.fp
+#include texsimple_xxx.fp
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_gl2.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_gl2.fp
index 6e0e7063c..31a63e6a4 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_gl2.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_gl2.fp
@@ -4,4 +4,4 @@
uniform sampler2D mgl_ActiveTexture;
-#include moviesimple_xxx.fp
+#include texsimple_xxx.fp
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_gl2.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_gl2.vp
index f8675eea4..8fcdc0ac9 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_gl2.vp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_gl2.vp
@@ -2,4 +2,4 @@
#version 110
-#include moviesimple_xxx.vp \ No newline at end of file
+#include texsimple_xxx.vp
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_xxx.fp
index d32c1d293..1465b28ed 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_xxx.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_xxx.fp
@@ -5,7 +5,12 @@ varying vec4 frontColor;
void main (void)
{
- vec4 texColor = texture2D(mgl_ActiveTexture, mgl_texCoord);
+ vec4 texColor;
+ if(0.0 <= mgl_texCoord.t && mgl_texCoord.t<=1.0) {
+ texColor = texture2D(mgl_ActiveTexture, mgl_texCoord);
+ } else {
+ texColor = vec4(1, 1, 1, 1);
+ }
// mix frontColor with texture ..
gl_FragColor = vec4(frontColor*texColor);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_xxx.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_xxx.vp
index dea57ca9e..dea57ca9e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_xxx.vp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texsimple_xxx.vp