aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2012-04-06 03:56:18 +0200
committerSven Gothel <sgothel@jausoft.com>2012-04-06 03:56:18 +0200
commit9bb8fe7c2baff185a62cf4806cfa34dfad4f7a4c (patch)
tree021d9139845ff9f91c5d8fa8e5354a8d30d67182 /src/test/com
parent7c78d722afab67a90bf92cdd29244398d1f3e5cd (diff)
GLMediaPlayer: Add (c) tag; Add NullGLMediaPlayer (dummy texture);
- Factory falls back to NullGLMediaPlayer allowing to test on platforms where no player is available. - MovieSimple (c) to JogAmp since it is no more derived from the old project.
Diffstat (limited to 'src/test/com')
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java5
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java3
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java3
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java1
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java408
5 files changed, 230 insertions, 190 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
index c52aea086..43bfd5f61 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
@@ -71,8 +71,9 @@ public class MovieSimpleActivity extends NewtBaseActivity {
final boolean mPlayerLocal = Boolean.valueOf(System.getProperty("jnlp.mplayer.local"));
final boolean mPlayerNormal = Boolean.valueOf(System.getProperty("jnlp.mplayer.normal"));
+ final boolean mPlayerNoZoom = Boolean.valueOf(System.getProperty("jnlp.mplayer.nozoom"));
final boolean mPlayerShared = !mPlayerNormal && Boolean.valueOf(System.getProperty("jnlp.mplayer.shared"));
- Log.d(TAG, "onCreate - 0 - mPlayerLocal "+mPlayerLocal+", mPlayerNormal "+mPlayerNormal+", mPlayerShared "+mPlayerShared);
+ Log.d(TAG, "onCreate - 0 - mPlayerLocal "+mPlayerLocal+", mPlayerNormal "+mPlayerNormal+", mPlayerNoScale "+mPlayerNoZoom+", mPlayerShared "+mPlayerShared);
String[] urls0 = new String[] {
System.getProperty("jnlp.media0_url2"),
@@ -133,7 +134,7 @@ public class MovieSimpleActivity extends NewtBaseActivity {
demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP);
demoMain.setTransparency(0.9f);
}
- demoMain.setScaleOrig(mPlayerNormal);
+ demoMain.setScaleOrig(mPlayerNoZoom);
final GLWindow glWindowMain = GLWindow.create(scrn, capsMain);
glWindowMain.setFullscreen(true);
// setContentView(getWindow(), glWindowMain);
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java
index b95e5f883..0fdd2297e 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java
@@ -32,7 +32,7 @@ import java.util.List;
import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
-public class MovieSimpleActivityLauncher00 extends LauncherUtil.BaseActivityLauncher {
+public class MovieSimpleActivityLauncher00a 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" };
@@ -42,6 +42,7 @@ public class MovieSimpleActivityLauncher00 extends LauncherUtil.BaseActivityLaun
public void init() {
final OrderedProperties props = getProperties();
props.setProperty("jnlp.mplayer.normal", "true");
+ props.setProperty("jnlp.mplayer.nozoom", "true");
props.setProperty("jnlp.mplayer.shared", "false");
props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v");
props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4");
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
index 28ac3b1a1..9e4823a04 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
@@ -32,7 +32,7 @@ import java.util.List;
import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
-public class MovieSimpleActivityLauncher01 extends LauncherUtil.BaseActivityLauncher {
+public class MovieSimpleActivityLauncher01a 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" };
@@ -42,6 +42,7 @@ public class MovieSimpleActivityLauncher01 extends LauncherUtil.BaseActivityLaun
public void init() {
final OrderedProperties props = getProperties();
props.setProperty("jnlp.mplayer.normal", "false");
+ props.setProperty("jnlp.mplayer.nozoom", "true");
props.setProperty("jnlp.mplayer.shared", "true");
props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v");
props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4");
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
index ec7f8738f..a907f063a 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
@@ -42,6 +42,7 @@ public class MovieSimpleActivityLauncher02 extends LauncherUtil.BaseActivityLaun
public void init() {
final OrderedProperties props = getProperties();
props.setProperty("jnlp.mplayer.normal", "false");
+ props.setProperty("jnlp.mplayer.nozoom", "false");
props.setProperty("jnlp.mplayer.shared", "false");
props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v");
props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4");
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 d5538c537..dc1d97396 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
@@ -1,42 +1,37 @@
-/*
- * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+/**
+ * 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:
*
- * 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.
*
- * - Redistribution 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.
*
- * - 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.
+ * 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.junit.jogl.demos.es2.av;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLConnection;
import java.nio.FloatBuffer;
import javax.media.opengl.GL;
@@ -52,14 +47,19 @@ 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.av.GLMediaPlayer;
import com.jogamp.opengl.av.GLMediaEventListener;
import com.jogamp.opengl.av.GLMediaPlayer.TextureFrame;
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.glsl.ShaderCode;
@@ -68,23 +68,28 @@ 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 boolean quit = false;
+public class MovieSimple implements GLEventListener, GLMediaEventListener {
private int winWidth, winHeight;
private int prevMouseX; // , prevMouseY;
- private boolean rotate = false;
- private float zoom = -2.5f;
- private float ang = 0f;
+ private int rotate = 0;
+ private boolean orthoProjection = true;
+ private float nearPlaneNormalized;
+ private float zoom0;
+ private float zoom1;
+ private float zoom;
private long startTime;
- private long curTime;
private int effects = EFFECT_NORMAL;
private float alpha = 1.0f;
private int texUnit = 0;
- public static final int EFFECT_NORMAL = 0;
+ 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 static final int EFFECT_TRANSPARENT = 1<<3;
+ /** defaults to true */
+ public void setOrthoProjection(boolean v) { orthoProjection=v; }
+ public boolean getOrthoProjection() { return orthoProjection; }
+
public void setTextureUnit(int u) { texUnit = u; }
public int getTextureUnit() { return texUnit; }
@@ -95,65 +100,60 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
this.alpha = alpha;
}
- public void changedAttributes(GLMediaPlayer omx, int event_mask) {
- System.out.println("changed stream attr ("+event_mask+"): "+omx);
- }
-
- public void mouseClicked(MouseEvent e) {
- switch(e.getClickCount()) {
- case 2:
- quit=true;
- break;
+ private final MouseListener mouseAction = new MouseAdapter() {
+ 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 mouseEntered(MouseEvent e) {
- }
- 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();
+ public void mouseReleased(MouseEvent e) {
+ if(e.getY()<=winHeight/2) {
+ rotate = -1;
+ zoom = zoom0;
+ System.err.println("zoom: "+zoom);
+ }
+ }
+ public void mouseMoved(MouseEvent e) {
+ prevMouseX = e.getX();
+ // prevMouseY = e.getY();
+ }
+ public void mouseDragged(MouseEvent e) {
+ 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 = 1;
+ zoom = zoom1;
}
+
+ prevMouseX = x;
+ // prevMouseY = y;
}
- }
- public void mouseReleased(MouseEvent e) {
- 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) {
- 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;
+ public void mouseWheelMoved(MouseEvent e) {
+ int r = e.getWheelRotation();
+ if(r>0) {
+ zoom += 0.1;
+ } else if(r<0) {
+ zoom -= 0.1;
+ }
+ System.err.println("zoom: "+zoom);
}
-
- prevMouseX = x;
- // prevMouseY = y;
- }
- public void mouseWheelMoved(MouseEvent e) {
- }
+ };
GLMediaPlayer mPlayer;
boolean mPlayerExternal;
boolean mPlayerShared;
boolean mPlayerScaleOrig;
- public MovieSimple(URL stream) throws IOException {
+ public MovieSimple(URLConnection stream) throws IOException {
mPlayerScaleOrig = false;
mPlayerExternal = false;
mPlayer = GLMediaPlayerFactory.create();
@@ -174,44 +174,42 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
System.out.println("p0.2 shared "+mPlayerShared+", "+mPlayer);
}
+ public GLMediaPlayer getGLMediaPlayer() { return mPlayer; }
+
public void setScaleOrig(boolean v) {
mPlayerScaleOrig = v;
}
- private void run() {
- System.err.println("MovieSimple.run()");
- try {
- GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
- GLWindow window = GLWindow.create(caps);
-
- window.addGLEventListener(this);
-
- // Size OpenGL to Video Surface
- window.setFullscreen(true);
- window.setVisible(true);
+ @Override
+ public void attributesChanges(GLMediaPlayer mp, int event_mask) {
+ System.out.println("attributesChanges: "+mp+", 0x"+Integer.toHexString(event_mask));
+ }
- while (!quit) {
- window.display();
- }
+ @Override
+ public void newFrameAvailable(GLMediaPlayer mp, TextureFrame frame) {
+ // System.out.println("newFrameAvailable: "+mp+", "+frame);
+ }
- // Shut things down cooperatively
- if(null!=mPlayer) {
- mPlayer.destroy(window.getGL());
- mPlayer=null;
- }
- window.destroy();
- System.out.println("MovieSimple shut down cleanly.");
- } catch (Throwable t) {
- t.printStackTrace();
- }
+ public void start() {
+ if(null!=mPlayer) {
+ mPlayer.start();
+ System.out.println("pStart "+mPlayer);
+ }
}
+ public void stop() {
+ if(null!=mPlayer) {
+ mPlayer.stop();
+ System.out.println("pStop "+mPlayer);
+ }
+ }
+
ShaderState st;
PMVMatrix pmvMatrix;
GLUniformData pmvMatrixUniform;
private void initShader(GL2ES2 gl, boolean useExternalTexture) {
-// Create & Compile the shader objects
+ // 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";
@@ -234,6 +232,10 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
}
public void init(GLAutoDrawable drawable) {
+ zoom0 = orthoProjection ? 0f : -2.5f;
+ zoom1 = orthoProjection ? 0f : -5f;
+ zoom = zoom0;
+
GL2ES2 gl = drawable.getGL().getGL2ES2();
System.err.println(JoglVersion.getGLInfo(gl, null));
System.err.println("Alpha: "+alpha+", opaque "+drawable.getChosenGLCapabilities().isBackgroundOpaque()+
@@ -252,7 +254,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
if(!mPlayerShared) {
mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_LINEAR } );
}
- } catch (GLException glex) {
+ } catch (Exception glex) {
if(!mPlayerShared && null != mPlayer) {
mPlayer.destroy(gl);
mPlayer = null;
@@ -260,18 +262,14 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
throw new GLException(glex);
}
- pmvMatrix = new PMVMatrix();
-
initShader(gl, useExternalTexture);
// Push the 1st uniform down the path
st.useProgram(gl, true);
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
- pmvMatrix.glLoadIdentity();
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmvMatrix.glLoadIdentity();
-
+ int[] viewPort = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight()};
+ pmvMatrix = new PMVMatrix();
+ reshapePMV(viewPort[2], viewPort[3]);
pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
if(!st.uniform(gl, pmvMatrixUniform)) {
throw new GLException("Error setting PMVMatrix in shader: "+st);
@@ -285,19 +283,36 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
float dHeight = drawable.getHeight();
float mWidth = mPlayer.getWidth();
float mHeight = mPlayer.getHeight();
- float aspect = mWidth/mHeight;
- float xoff, yoff;
- float xs, ys; // scale object
- float ss, ts; // scale tex-coord
- if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) {
- xoff = ((dWidth-mWidth)/2f)/dWidth; yoff = ((dHeight-mHeight)/2f)/dHeight;
- xs = aspect * ( mWidth / dWidth ); ys = mHeight/dHeight;
- ss = 1f; ts = 1f;
+ float mAspect = mWidth/mHeight;
+ float[] verts;
+ float xs, ys;
+ if(orthoProjection) {
+ if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) {
+ xs = mWidth/2f; ys = xs / mAspect;
+ } else {
+ xs = dWidth/2f; ys = xs / mAspect; // w>h
+ }
} else {
- xoff = 0f; yoff = 0f;
- xs = aspect; ys = 1f; // b>h
- ss = 1f; ts = 1f; // b>h
+ if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) {
+ xs = mAspect * ( mWidth / dWidth ) ; ys = xs / mAspect ;
+ } else {
+ xs = mAspect; ys = 1f; // b>h
+ }
}
+ verts = new float[] { -1f*xs, -1f*ys, 0f, // LB
+ 1f*xs, 1f*ys, 0f // RT
+ };
+ {
+ System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]);
+ System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]);
+ float[] winLB = new float[3];
+ float[] winRT = new float[3];
+ pmvMatrix.gluProject(verts[0], verts[1], verts[2], viewPort, 0, winLB, 0);
+ pmvMatrix.gluProject(verts[3], verts[4], verts[5], viewPort, 0, winRT, 0);
+ System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]);
+ System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]);
+ }
+ final float ss = 1f, ts = 1f; // scale tex-coord
final GLArrayDataServer interleaved = GLArrayDataServer.createGLSLInterleaved(9, GL.GL_FLOAT, false, 12, GL.GL_STATIC_DRAW);
{
@@ -310,9 +325,9 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
GLArrayData colors = interleaved.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
FloatBuffer colorb = (FloatBuffer)colors.getBuffer();
-
+
// left-bottom
- verticeb.put(-1f*xs+xoff); verticeb.put( -1f*ys+yoff); verticeb.put( 0);
+ verticeb.put(verts[0]); verticeb.put(verts[1]); verticeb.put(verts[2]);
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);
@@ -321,7 +336,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
}
// right-bottom
- verticeb.put( 1f*xs+xoff); verticeb.put( -1f*ys+yoff); verticeb.put( 0);
+ verticeb.put(verts[3]); verticeb.put(verts[1]); verticeb.put(verts[2]);
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);
@@ -330,7 +345,7 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
}
// left-top
- verticeb.put(-1f*xs+xoff); verticeb.put( 1f*ys+yoff); verticeb.put( 0);
+ verticeb.put(verts[0]); verticeb.put(verts[4]); verticeb.put(verts[2]);
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);
@@ -339,18 +354,20 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
}
// right-top
- verticeb.put( 1f*xs+xoff); verticeb.put( 1f*ys+yoff); verticeb.put( 0);
+ verticeb.put(verts[3]); verticeb.put(verts[4]); verticeb.put(verts[2]);
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);
- }
+ }
}
interleaved.seal(gl, true);
// OpenGL Render Settings
- gl.glClearColor(0f, 0f, 0f, 0f);
+ // gl.glClearColor(0f, 0f, 0f, 0f);
+ // gl.glClearColor(0.9f, 0.9f, 0.9f, 0.3f);
+ gl.glClearColor(0.1f, 0.1f, 0.1f, 0.4f);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
@@ -368,49 +385,45 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
if (drawable instanceof Window) {
Window window = (Window) drawable;
- window.addMouseListener(this);
+ window.addMouseListener(mouseAction);
winWidth = window.getWidth();
winHeight = window.getHeight();
}
}
- public void start() {
- if(null!=mPlayer) {
- mPlayer.start();
- System.out.println("pStart "+mPlayer);
- }
- }
-
- public void stop() {
- if(null!=mPlayer) {
- mPlayer.stop();
- System.out.println("pStop "+mPlayer);
- }
- }
-
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
if(null == mPlayer) { return; }
winWidth = width;
winHeight = height;
+ reshapePMV(width, height);
+
GL2ES2 gl = drawable.getGL().getGL2ES2();
st.useProgram(gl, true);
-
- // Set location in front of camera
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+
+ System.out.println("p2 "+mPlayer);
+ }
+
+ private void reshapePMV(int width, int height) {
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmvMatrix.glLoadIdentity();
- pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1.0f, 100.0f);
- //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f);
+ if(orthoProjection) {
+ float fw = (float) width;
+ float fh = (float) height;
+ pmvMatrix.glOrthof(-fw/2f, fw/2f, -fh/2f, fh/2f, -1.0f, 1.0f);
+ nearPlaneNormalized = 0f;
+ } else {
+ pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1f, 10.0f);
+ nearPlaneNormalized = 1f/(10f-1f);
+ }
+ System.err.println("XXX0: Perspective nearPlaneNormalized: "+nearPlaneNormalized);
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmvMatrix.glLoadIdentity();
- pmvMatrix.glTranslatef(0, 0, zoom);
- st.uniform(gl, pmvMatrixUniform);
-
- st.useProgram(gl, false);
-
- System.out.println("p2 "+mPlayer);
+ pmvMatrix.glTranslatef(0, 0, zoom0);
}
public void dispose(GLAutoDrawable drawable) {
@@ -430,7 +443,6 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
pmvMatrix=null;
st.destroy(gl);
st=null;
- quit=true;
}
public void display(GLAutoDrawable drawable) {
@@ -442,22 +454,16 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- if(rotate) {
- curTime = System.currentTimeMillis();
- ang = ((float) (curTime - startTime) * 360.0f) / 8000.0f;
- }
-
- if(rotate || zoom!=0f) {
- pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
- pmvMatrix.glLoadIdentity();
- pmvMatrix.glTranslatef(0, 0, zoom);
+ pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
+ pmvMatrix.glLoadIdentity();
+ pmvMatrix.glTranslatef(0, 0, zoom);
+ if(rotate > 0) {
+ final float ang = ((float) (System.currentTimeMillis() - startTime) * 360.0f) / 8000.0f;
pmvMatrix.glRotatef(ang, 0, 0, 1);
- st.uniform(gl, pmvMatrixUniform);
-
- if(!rotate) {
- zoom=0f;
- }
+ } else {
+ rotate = 0;
}
+ st.uniform(gl, pmvMatrixUniform);
final Texture tex;
if(null!=mPlayer) {
@@ -489,19 +495,49 @@ public class MovieSimple implements MouseListener, GLEventListener, GLMediaEvent
}
public static void main(String[] args) throws IOException, MalformedURLException {
- String fname="file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4";
- if(args.length>0) fname=args[0];
- new MovieSimple(new URL(fname)).run();
- System.exit(0);
- }
+ int w = 640;
+ int h = 480;
+ boolean ortho = true;
+ boolean zoom = false;
+
+ String url_s="file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4";
+ for(int i=0; i<args.length; i++) {
+ if(args[i].equals("-width")) {
+ i++;
+ w = MiscUtils.atoi(args[i], w);
+ } else if(args[i].equals("-height")) {
+ i++;
+ h = MiscUtils.atoi(args[i], h);
+ } else if(args[i].equals("-projection")) {
+ ortho=false;
+ } else if(args[i].equals("-zoom")) {
+ zoom=true;
+ } else if(args[i].equals("-url")) {
+ i++;
+ url_s = args[i];
+ }
+ }
+ MovieSimple ms = new MovieSimple(new URL(url_s).openConnection());
+ ms.setScaleOrig(!zoom);
+ ms.setOrthoProjection(ortho);
+
+ try {
+ GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ GLWindow window = GLWindow.create(caps);
- @Override
- public void attributesChanges(GLMediaPlayer mp, int event_mask) {
- System.out.println("attributesChanges: "+mp+", 0x"+Integer.toHexString(event_mask));
- }
+ window.addGLEventListener(ms);
- @Override
- public void newFrameAvailable(GLMediaPlayer mp, TextureFrame frame) {
- // System.out.println("newFrameAvailable: "+mp+", "+frame);
+ window.setSize(w, h);
+ window.setVisible(true);
+ final Animator anim = new Animator(window);
+ anim.start();
+ window.addWindowListener(new WindowAdapter() {
+ public void windowDestroyed(WindowEvent e) {
+ anim.stop();
+ }
+ });
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
}