summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/resources/android/AndroidManifest-test.xml10
-rw-r--r--make/resources/android/res-test/values/strings.xml2
-rwxr-xr-xmake/scripts/adb-power-alwayson.sh3
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java130
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher.java74
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java262
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.fp10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.vp16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_exttex.fp18
9 files changed, 411 insertions, 114 deletions
diff --git a/make/resources/android/AndroidManifest-test.xml b/make/resources/android/AndroidManifest-test.xml
index ca3089098..84256f6f4 100644
--- a/make/resources/android/AndroidManifest-test.xml
+++ b/make/resources/android/AndroidManifest-test.xml
@@ -95,6 +95,16 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+ <activity android:name="com.jogamp.opengl.test.android.MovieSimpleActivityLauncher"
+ android:label="@string/activity_moviesimple_name"
+ android:description="@string/activity_moviesimple_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 d66f6e4d7..ea366a9f9 100644
--- a/make/resources/android/res-test/values/strings.xml
+++ b/make/resources/android/res-test/values/strings.xml
@@ -19,4 +19,6 @@
<string name="activity_graphui2p_descr">GraphUI 2-pass</string>
<string name="activity_elektro_name">Elektro</string>
<string name="activity_elektro_descr">Elektro</string>
+ <string name="activity_moviesimple_name">MovieSimple</string>
+ <string name="activity_moviesimple_descr">MovieSimple</string>
</resources>
diff --git a/make/scripts/adb-power-alwayson.sh b/make/scripts/adb-power-alwayson.sh
new file mode 100755
index 000000000..ec04064be
--- /dev/null
+++ b/make/scripts/adb-power-alwayson.sh
@@ -0,0 +1,3 @@
+sdir=`dirname $0`
+
+adb $* shell svc power stayon true
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
new file mode 100644
index 000000000..7505d4659
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
@@ -0,0 +1,130 @@
+/**
+ * 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.net.MalformedURLException;
+import java.net.URL;
+
+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.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.MovieSimple;
+import com.jogamp.opengl.util.Animator;
+
+import android.os.Bundle;
+import android.util.Log;
+
+public class MovieSimpleActivity extends NewtBaseActivity {
+ static String TAG = "NEWTGearsES2Activity";
+
+ MouseAdapter demoMouseListener = new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ Object src = e.getSource();
+ if(src instanceof AndroidWindow) {
+ ((AndroidWindow)src).getAndroidView().bringToFront();
+ }
+ } };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ Log.d(TAG, "onCreate - 0");
+ super.onCreate(savedInstanceState);
+
+ setTransparencyTheme();
+ setFullscreenFeature(getWindow(), true);
+
+ android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext());
+ getWindow().setContentView(viewGroup);
+
+ // 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();
+
+ final GLWindow glWindowMain = GLWindow.create(scrn, capsMain);
+ glWindowMain.addMouseListener(demoMouseListener);
+ glWindowMain.setFullscreen(true);
+ // setContentView(getWindow(), glWindowMain);
+ viewGroup.addView(((AndroidWindow)glWindowMain.getDelegatedWindow()).getAndroidView(), 0);
+ registerNEWTWindow(glWindowMain);
+
+ final GLCapabilities capsHUD = new GLCapabilities(GLProfile.getGL2ES2());
+
+ final GLWindow glWindowHUD = GLWindow.create(scrn, capsHUD);
+ glWindowHUD.addMouseListener(demoMouseListener);
+ {
+ int x2 = scrn.getX();
+ int y2 = scrn.getY();
+ int w2 = scrn.getWidth()/4;
+ int h2 = scrn.getHeight()/4;
+ glWindowHUD.setPosition(x2, y2);
+ glWindowHUD.setSize(w2, h2);
+ }
+ // addContentView(getWindow(), glWindowHUD, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight()));
+ viewGroup.addView(((AndroidWindow)glWindowHUD.getDelegatedWindow()).getAndroidView(), 1, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight()));
+ registerNEWTWindow(glWindowHUD);
+
+ try {
+ Animator animator = new Animator();
+ setAnimator(animator);
+
+ final MovieSimple demoMain = new MovieSimple(new URL("file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"));
+ demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP);
+ demoMain.setTransparency(0.9f);
+ glWindowMain.addGLEventListener(demoMain);
+ animator.add(glWindowMain);
+ glWindowMain.setVisible(true);
+
+ final MovieSimple demoHUD = new MovieSimple(new URL("file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"));
+ glWindowHUD.addGLEventListener(demoHUD);
+ animator.add(glWindowHUD);
+ glWindowHUD.setVisible(true);
+
+ // animator.setUpdateFPSFrames(60, System.err);
+ animator.resetFPSCounter();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+
+ scrn.removeReference();
+
+ Log.d(TAG, "onCreate - X");
+ }
+}
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher.java
new file mode 100644
index 000000000..36bdd2921
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher.java
@@ -0,0 +1,74 @@
+/**
+ * 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 MovieSimpleActivityLauncher extends LauncherUtil.BaseActivityLauncher {
+
+ static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity";
+ // 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("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/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java
index f58938399..9730a16c5 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
@@ -35,19 +35,23 @@
package com.jogamp.opengl.test.junit.jogl.demos.es2.av;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
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;
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.MouseEvent;
import com.jogamp.newt.event.MouseListener;
import com.jogamp.newt.opengl.GLWindow;
@@ -60,17 +64,33 @@ 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.TextureCoords;
public class MovieSimple implements MouseListener, GLEventListener, GLMediaEventListener {
- private GLWindow window;
private boolean quit = false;
+ private int winWidth, winHeight;
+ private int prevMouseX; // , prevMouseY;
private boolean rotate = false;
private float zoom = -2.5f;
private float ang = 0f;
private long startTime;
private long curTime;
- private String stream;
-
+ private URL stream;
+ private int effects = EFFECT_NORMAL;
+ private float alpha = 1.0f;
+
+ public static final int EFFECT_NORMAL = 0;
+ public static final int EFFECT_GRADIENT_BOTTOM2TOP = 1<<1;
+ public static final int EFFECT_TRANSPARENT = 1<<3;
+
+ public boolean hasEffect(int e) { return 0 != ( effects & e ) ; }
+ public void setEffects(int e) { effects = e; };
+ public void setTransparency(float alpha) {
+ this.effects |= EFFECT_TRANSPARENT;
+ this.alpha = alpha;
+ }
+
public void changedAttributes(GLMediaPlayer omx, int event_mask) {
System.out.println("changed stream attr ("+event_mask+"): "+omx);
}
@@ -87,21 +107,44 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
+ if(e.getY()<=winHeight/2 && null!=mPlayer && 1 == e.getClickCount()) {
+ if(GLMediaPlayer.State.Playing == mPlayer.getState()) {
+ mPlayer.pause();
+ } else {
+ mPlayer.start();
+ }
+ }
}
public void mouseReleased(MouseEvent e) {
- rotate = false;
- zoom = -2.5f;
+ if(e.getY()<=winHeight/2) {
+ rotate = false;
+ zoom = -2.5f;
+ }
}
public void mouseMoved(MouseEvent e) {
+ prevMouseX = e.getX();
+ // prevMouseY = e.getY();
}
public void mouseDragged(MouseEvent e) {
- rotate = true;
- zoom = -5;
+ int x = e.getX();
+ int y = e.getY();
+
+ if(y>winHeight/2) {
+ final float dp = (float)(x-prevMouseX)/(float)winWidth;
+ mPlayer.seek(mPlayer.getCurrentPosition() + (long) (mPlayer.getDuration() * dp));
+ } else {
+ mPlayer.start();
+ rotate = true;
+ zoom = -5;
+ }
+
+ prevMouseX = x;
+ // prevMouseY = y;
}
public void mouseWheelMoved(MouseEvent e) {
}
- public MovieSimple(String stream) {
+ public MovieSimple(URL stream) {
this.stream = stream ;
}
@@ -109,32 +152,22 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
System.err.println("MovieSimple.run()");
try {
GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
- // For emulation library, use 16 bpp
- caps.setRedBits(5);
- caps.setGreenBits(6);
- caps.setBlueBits(5);
- caps.setDepthBits(16);
-
- window = GLWindow.create(caps);
+ GLWindow window = GLWindow.create(caps);
- window.addMouseListener(this);
window.addGLEventListener(this);
- // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default
- // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current ..
// Size OpenGL to Video Surface
window.setFullscreen(true);
window.setVisible(true);
- startTime = System.currentTimeMillis();
while (!quit) {
window.display();
}
// Shut things down cooperatively
- if(null!=movie) {
- movie.destroy(window.getGL());
- movie=null;
+ if(null!=mPlayer) {
+ mPlayer.destroy(window.getGL());
+ mPlayer=null;
}
window.destroy();
System.out.println("MovieSimple shut down cleanly.");
@@ -145,13 +178,17 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
ShaderState st;
PMVMatrix pmvMatrix;
-
- private void initShader(GL2ES2 gl) {
+ GLUniformData pmvMatrixUniform;
+
+ private void initShader(GL2ES2 gl, boolean useExternalTexture) {
// Create & Compile the shader objects
+ final String vShaderBasename = "moviesimple" ;
+ final String fShaderBasename = useExternalTexture ? "moviesimple_exttex" : "moviesimple" ;
+
ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, MovieSimple.class,
- "shader", "shader/bin", "moviesimple");
+ "../shader", "../shader/bin", vShaderBasename);
ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, MovieSimple.class,
- "shader", "shader/bin", "moviesimple");
+ "../shader", "../shader/bin", fShaderBasename);
// Create & Link the shader program
ShaderProgram sp = new ShaderProgram();
@@ -166,7 +203,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
st.attachShaderProgram(gl, sp, false);
}
- GLMediaPlayer movie=null;
+ GLMediaPlayer mPlayer=null;
public void init(GLAutoDrawable drawable) {
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -174,10 +211,23 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
System.err.println("GL_VERSION=" + gl.glGetString(GL.GL_VERSION));
System.err.println("GL_EXTENSIONS:");
System.err.println(" " + gl.glGetString(GL.GL_EXTENSIONS));
+ System.err.println("Alpha: "+alpha+", opaque "+drawable.getChosenGLCapabilities().isBackgroundOpaque()+
+ ", "+drawable.getClass().getName()+", "+drawable);
+ boolean useExternalTexture = false;
+ try {
+ mPlayer = GLMediaPlayerFactory.create();
+ mPlayer.addEventListener(this);
+ // movie.setStream(4, new URL(stream));
+ mPlayer.setStream(gl, stream);
+ System.out.println("p0 "+mPlayer);
+ useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == mPlayer.getTextureTarget();
+ mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_LINEAR } );
+ } catch (IOException ioe) { ioe.printStackTrace(); }
+
pmvMatrix = new PMVMatrix();
- initShader(gl);
+ initShader(gl, useExternalTexture);
// Push the 1st uniform down the path
st.useProgram(gl, true);
@@ -187,14 +237,16 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- if(!st.uniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) {
+ pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
+ if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
}
+ final GLMediaPlayer.TextureFrame texFrame = mPlayer.getLastTexture();
if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) {
throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
}
gl.glActiveTexture(GL.GL_TEXTURE0);
-
+
float aspect = 16.0f/9.0f;
float xs=1f, ys=1f; // scale object
float ss=1f, ts=1f; // scale tex-coord
@@ -204,43 +256,59 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
// ss = 1f/aspect; // b > h, crop width
// ts = 1f; // b > h
- // Allocate vertex array
- GLArrayDataServer vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
- {
- // Fill them up
+ final GLArrayDataServer interleaved = GLArrayDataServer.createGLSLInterleaved(9, GL.GL_FLOAT, false, 12, GL.GL_STATIC_DRAW);
+ {
+ GLArrayData vertices = interleaved.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer();
+
+ GLArrayData texcoord = interleaved.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
+ TextureCoords tc = texFrame.getTexture().getImageTexCoords();
+ FloatBuffer texcoordb = (FloatBuffer)texcoord.getBuffer();
+
+ GLArrayData colors = interleaved.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
+ FloatBuffer colorb = (FloatBuffer)colors.getBuffer();
+
+ // left-bottom
verticeb.put(-1f*xs); verticeb.put( -1f*ys); verticeb.put( 0);
- verticeb.put(-1f*xs); verticeb.put( 1f*ys); verticeb.put( 0);
+ texcoordb.put( tc.left() *ss); texcoordb.put( tc.bottom() *ts);
+ if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
+ colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put(alpha);
+ } else {
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ }
+
+ // right-bottom
verticeb.put( 1f*xs); verticeb.put( -1f*ys); verticeb.put( 0);
- verticeb.put( 1f*xs); verticeb.put( 1f*ys); verticeb.put( 0);
- }
- vertices.seal(gl, true);
-
- // Allocate texcoord array
- GLArrayDataServer texcoord = GLArrayDataServer.createGLSL("mgl_MultiTexCoord", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
- {
- // Fill them up
- FloatBuffer texcoordb = (FloatBuffer)texcoord.getBuffer();
- texcoordb.put( 0f*ss); texcoordb.put( 0f*ts);
- texcoordb.put( 0f*ss); texcoordb.put( 1f*ts);
- texcoordb.put( 1f*ss); texcoordb.put( 0f*ts);
- texcoordb.put( 1f*ss); texcoordb.put( 1f*ts);
- }
- texcoord.seal(gl, true);
+ texcoordb.put( tc.right() *ss); texcoordb.put( tc.bottom() *ts);
+ if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
+ colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put(alpha);
+ } else {
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ }
- GLArrayDataServer colors = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW);
- {
- // Fill them up
- FloatBuffer colorb = (FloatBuffer)colors.getBuffer();
- colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put( 1);
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put( 1);
- colorb.put( 0); colorb.put( 0); colorb.put( 0); colorb.put( 1);
- colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put( 1);
+ // left-top
+ verticeb.put(-1f*xs); verticeb.put( 1f*ys); verticeb.put( 0);
+ texcoordb.put( tc.left() *ss); texcoordb.put( tc.top() *ts);
+ if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ } else {
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ }
+
+ // right-top
+ verticeb.put( 1f*xs); verticeb.put( 1f*ys); verticeb.put( 0);
+ texcoordb.put( tc.right() *ss); texcoordb.put( tc.top() *ts);
+ if( hasEffect(EFFECT_GRADIENT_BOTTOM2TOP) ) {
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ } else {
+ colorb.put( 1); colorb.put( 1); colorb.put( 1); colorb.put(alpha);
+ }
}
- colors.seal(gl, true);
+ interleaved.seal(gl, true);
// OpenGL Render Settings
- gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
+ gl.glClearColor(0f, 0f, 0f, 0f);
+
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
st.useProgram(gl, false);
@@ -248,22 +316,24 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
// Let's show the completed shader state ..
System.out.println(st);
- try {
- movie = GLMediaPlayerFactory.create();
- movie.addEventListener(this);
- // movie.setStream(4, new URL(stream));
- movie.setStream(gl, new URL(stream));
- System.out.println("p0 "+movie);
- } catch (IOException ioe) { ioe.printStackTrace(); }
- if(null!=movie) {
- //movie.setStreamAllEGLImageTexture2D(gl);
- //movie.activateStream();
- //System.out.println("p1 "+movie);
- movie.start();
+ startTime = System.currentTimeMillis();
+
+ if(null!=mPlayer) {
+ System.out.println("p1 "+mPlayer);
+ mPlayer.start();
+ }
+ if (drawable instanceof Window) {
+ Window window = (Window) drawable;
+ window.addMouseListener(this);
+ winWidth = window.getWidth();
+ winHeight = window.getHeight();
}
}
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ winWidth = width;
+ winHeight = height;
+
GL2ES2 gl = drawable.getGL().getGL2ES2();
st.useProgram(gl, true);
@@ -277,21 +347,19 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
pmvMatrix.glTranslatef(0, 0, zoom);
-
- GLUniformData ud = st.getUniform("mgl_PMVMatrix");
- if(null!=ud) {
- // same data object
- st.uniform(gl, ud);
- }
+ st.uniform(gl, pmvMatrixUniform);
st.useProgram(gl, false);
+
+ System.out.println("p2 "+mPlayer);
}
public void dispose(GLAutoDrawable drawable) {
GL2ES2 gl = drawable.getGL().getGL2ES2();
- movie.destroy(gl);
- movie=null;
+ mPlayer.destroy(gl);
+ mPlayer=null;
+ pmvMatrixUniform = null;
pmvMatrix.destroy();
pmvMatrix=null;
st.destroy(gl);
@@ -316,27 +384,19 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
pmvMatrix.glLoadIdentity();
pmvMatrix.glTranslatef(0, 0, zoom);
pmvMatrix.glRotatef(ang, 0, 0, 1);
- // pmvMatrix.glRotatef(ang, 0, 1, 0);
-
- GLUniformData ud = st.getUniform("mgl_PMVMatrix");
- if(null!=ud) {
- // same data object
- st.uniform(gl, ud);
- }
+ st.uniform(gl, pmvMatrixUniform);
if(!rotate) {
zoom=0f;
}
}
-
- com.jogamp.opengl.util.texture.Texture tex = null;
- if(null!=movie) {
- tex=movie.getNextTextureID();
- if(null!=tex) {
- tex.enable(gl);
- tex.bind(gl);
- }
+ Texture tex = null;
+ if(null!=mPlayer) {
+ final GLMediaPlayer.TextureFrame texFrame=mPlayer.getNextTexture();
+ tex = texFrame.getTexture();
+ tex.enable(gl);
+ tex.bind(gl);
}
// Draw a square
@@ -352,22 +412,20 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}
- public static void main(String[] args) {
- String fname="file:///Storage Card/resources/a.mp4";
+ public static void main(String[] args) throws MalformedURLException {
+ String fname="file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4";
if(args.length>0) fname=args[0];
- new MovieSimple(fname).run();
+ new MovieSimple(new URL(fname)).run();
System.exit(0);
}
@Override
public void attributesChanges(GLMediaPlayer mp, int event_mask) {
- // TODO Auto-generated method stub
-
+ System.out.println("attributesChanges: "+mp+", 0x"+Integer.toHexString(event_mask));
}
@Override
public void newFrameAvailable(GLMediaPlayer mp, TextureFrame frame) {
- // TODO Auto-generated method stub
-
+ // System.out.println("newFrameAvailable: "+mp+", "+frame);
}
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.fp
index c71164105..d1ae39428 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.fp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.fp
@@ -7,15 +7,15 @@
#define HIGHP
#endif
-uniform sampler2D mgl_ActiveTexture;
-varying HIGHP vec4 mgl_texCoord;
-varying HIGHP vec4 frontColor;
+uniform sampler2D mgl_ActiveTexture;
+varying MEDIUMP vec2 mgl_texCoord;
+varying MEDIUMP vec4 frontColor;
void main (void)
{
- vec4 texColor = texture2D(mgl_ActiveTexture, mgl_texCoord.st);
+ HIGHP vec4 texColor = texture2D(mgl_ActiveTexture, mgl_texCoord);
// mix frontColor with texture ..
- gl_FragColor = vec4(frontColor.rgb*texColor.rgb, frontColor.a);
+ gl_FragColor = vec4(frontColor*texColor);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.vp
index 0b78eb913..9d609ab87 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.vp
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple.vp
@@ -7,16 +7,18 @@
#define HIGHP
#endif
-uniform MEDIUMP mat4 mgl_PMVMatrix[2];
-attribute HIGHP vec4 mgl_Vertex;
-attribute HIGHP vec4 mgl_Color;
-attribute HIGHP vec4 mgl_MultiTexCoord;
-varying HIGHP vec4 frontColor;
-varying HIGHP vec4 mgl_texCoord;
+uniform MEDIUMP mat4 mgl_PMVMatrix[2];
+// uniform MEDIUMP mat4 mgl_STMatrix;
+attribute MEDIUMP vec4 mgl_Vertex;
+attribute MEDIUMP vec4 mgl_Color;
+attribute MEDIUMP vec4 mgl_MultiTexCoord;
+varying MEDIUMP vec4 frontColor;
+varying MEDIUMP vec2 mgl_texCoord;
void main(void)
{
frontColor=mgl_Color;
- mgl_texCoord = mgl_MultiTexCoord;
+ // mgl_texCoord = (mgl_STMatrix * mgl_MultiTexCoord).st;
+ mgl_texCoord = mgl_MultiTexCoord.st;
gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex;
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_exttex.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_exttex.fp
new file mode 100644
index 000000000..8d1d60b1f
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/moviesimple_exttex.fp
@@ -0,0 +1,18 @@
+
+#extension GL_OES_EGL_image_external : require
+
+#define MEDIUMP mediump
+#define HIGHP highp
+
+uniform samplerExternalOES mgl_ActiveTexture;
+varying MEDIUMP vec2 mgl_texCoord;
+varying MEDIUMP vec4 frontColor;
+
+void main (void)
+{
+ HIGHP vec4 texColor = texture2D(mgl_ActiveTexture, mgl_texCoord);
+
+ // mix frontColor with texture ..
+ gl_FragColor = vec4(frontColor*texColor);
+}
+