aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/com/jogamp')
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java127
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java11
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java9
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java9
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java9
-rw-r--r--src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java9
-rwxr-xr-xsrc/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java106
7 files changed, 135 insertions, 145 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
index 43bfd5f61..86b3ffb48 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity.java
@@ -33,7 +33,6 @@ import java.util.Arrays;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLContext;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
@@ -47,12 +46,12 @@ import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.av.GLMediaPlayer;
-import com.jogamp.opengl.av.GLMediaPlayerFactory;
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;
+import android.view.Gravity;
public class MovieSimpleActivity extends NewtBaseActivity {
static String TAG = "NEWTGearsES2Activity";
@@ -70,10 +69,10 @@ public class MovieSimpleActivity extends NewtBaseActivity {
super.onCreate(savedInstanceState);
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+", mPlayerNoScale "+mPlayerNoZoom+", mPlayerShared "+mPlayerShared);
+ final boolean mPlayerHUD = Boolean.valueOf(System.getProperty("jnlp.mplayer.hud"));
+ final boolean mPlayerSharedHUD = mPlayerHUD && Boolean.valueOf(System.getProperty("jnlp.mplayer.hud.shared"));
+ Log.d(TAG, "onCreate - 0 - mPlayerLocal "+mPlayerLocal+", mPlayerNoScale "+mPlayerNoZoom+", mPlayerHUD "+mPlayerHUD+", mPlayerSharedHUD "+mPlayerSharedHUD);
String[] urls0 = new String[] {
System.getProperty("jnlp.media0_url2"),
@@ -85,7 +84,7 @@ public class MovieSimpleActivity extends NewtBaseActivity {
final URLConnection urlConnection1;
{
URLConnection _urlConnection1 = null;
- if(!mPlayerShared && !mPlayerNormal) {
+ if(mPlayerHUD && !mPlayerSharedHUD) {
String[] urls1 = new String[] { System.getProperty("jnlp.media1_url0") };
_urlConnection1 = getResource(urls1, 0);
}
@@ -101,8 +100,7 @@ public class MovieSimpleActivity extends NewtBaseActivity {
// also initializes JOGL
final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2());
- capsMain.setBackgroundOpaque(false);
- final GLCapabilities capsHUD = new GLCapabilities(GLProfile.getGL2ES2());
+ capsMain.setBackgroundOpaque(!mPlayerHUD);
// screen for layout params ..
final com.jogamp.newt.Display dpy = NewtFactory.createDisplay(null);
@@ -110,82 +108,79 @@ public class MovieSimpleActivity extends NewtBaseActivity {
scrn.addReference();
try {
- final GLMediaPlayer mPlayerMain = GLMediaPlayerFactory.create();
- mPlayerMain.initStream(urlConnection0);
-
- final GLMediaPlayer mPlayerHUD;
- if(!mPlayerNormal) {
- if(mPlayerShared) {
- mPlayerHUD = mPlayerMain;
- } else {
- mPlayerHUD = GLMediaPlayerFactory.create();
- mPlayerHUD.initStream(urlConnection1);
- }
- } else {
- mPlayerHUD = null;
- }
-
final Animator animator = new Animator();
setAnimator(animator);
// Main
- final MovieSimple demoMain = new MovieSimple(mPlayerMain, false);
- if(!mPlayerNormal) {
+ final MovieSimple demoMain = new MovieSimple(urlConnection0);
+ if(mPlayerHUD) {
demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP);
demoMain.setTransparency(0.9f);
}
demoMain.setScaleOrig(mPlayerNoZoom);
final GLWindow glWindowMain = GLWindow.create(scrn, capsMain);
- glWindowMain.setFullscreen(true);
- // setContentView(getWindow(), glWindowMain);
- viewGroup.addView(((AndroidWindow)glWindowMain.getDelegatedWindow()).getAndroidView());
- registerNEWTWindow(glWindowMain);
+ {
+ final int padding = mPlayerHUD ? 32 : 0;
+ final android.view.View androidView = ((AndroidWindow)glWindowMain.getDelegatedWindow()).getAndroidView();
+ glWindowMain.setSize(scrn.getWidth()-padding, scrn.getHeight()-padding);
+ glWindowMain.setUndecorated(true);
+ // setContentView(getWindow(), glWindowMain);
+ viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowMain.getWidth(), glWindowMain.getHeight(), Gravity.BOTTOM|Gravity.RIGHT));
+ registerNEWTWindow(glWindowMain);
+ }
+
glWindowMain.addGLEventListener(demoMain);
animator.add(glWindowMain);
glWindowMain.setVisible(true);
- if(null != mPlayerHUD) {
- final MovieSimple demoHUD = new MovieSimple(mPlayerHUD, mPlayerShared);
- final GLWindow glWindowHUD = GLWindow.create(scrn, capsHUD);
- glWindowHUD.addMouseListener(toFrontMouseListener);
- {
- int x2 = scrn.getX();
- int y2 = scrn.getY();
- int w2 = scrn.getWidth()/2;
- int h2 = scrn.getHeight()/2;
- if(0 < mPlayerHUD.getWidth() && mPlayerHUD.getWidth()<w2) {
- w2 = mPlayerHUD.getWidth();
- }
- if(0 < mPlayerHUD.getHeight() && mPlayerHUD.getHeight()<h2) {
- h2 = mPlayerHUD.getHeight();
- }
- glWindowHUD.setPosition(x2, y2);
- glWindowHUD.setSize(w2, h2);
- System.err.println("HUD: "+mPlayerHUD);
- System.err.println("HUD: "+w2+"x"+h2);
- }
- // addContentView(getWindow(), glWindowHUD, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight()));
- viewGroup.addView(((AndroidWindow)glWindowHUD.getDelegatedWindow()).getAndroidView(), new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight()));
- registerNEWTWindow(glWindowHUD);
- glWindowHUD.addGLEventListener(demoHUD);
- // Hand over shared ctx must happen while the shared GLWindow is
- // guaranteed to be initialized.
- glWindowMain.invoke(false, new GLRunnable() {
+ if(mPlayerHUD) {
+ final GLMediaPlayer sharedPlayer = mPlayerSharedHUD ? demoMain.getGLMediaPlayer() : null;
+ final GLCapabilities capsHUD = new GLCapabilities(GLProfile.getGL2ES2());
+ capsHUD.setBackgroundOpaque(false);
+ final GLWindow glWindowHUD = GLWindow.create(scrn, capsHUD);
+ glWindowMain.invoke(false, new GLRunnable() {
@Override
public boolean run(GLAutoDrawable drawable) {
- if(mPlayerShared) {
- GLContext sharedCtx = glWindowMain.getContext();
- System.err.println("Shared: "+sharedCtx);
- glWindowHUD.setSharedContext(sharedCtx);
- }
- animator.add(glWindowHUD);
- glWindowHUD.setVisible(true);
- glWindowHUD.requestFocus(false);
- return true;
+ int x2 = scrn.getX();
+ int y2 = scrn.getY();
+ int w2 = scrn.getWidth()/3;
+ int h2 = scrn.getHeight()/3;
+ if(null != sharedPlayer) {
+ if(0 < sharedPlayer.getWidth() && sharedPlayer.getWidth()<scrn.getWidth()/2 &&
+ 0 < sharedPlayer.getHeight() && sharedPlayer.getHeight()<scrn.getHeight()/2) {
+ w2 = sharedPlayer.getWidth();
+ h2 = sharedPlayer.getHeight();
+ }
+ glWindowHUD.setSharedContext(glWindowMain.getContext());
+ glWindowHUD.addGLEventListener(new MovieSimple(sharedPlayer));
+ } else {
+ try {
+ glWindowHUD.addGLEventListener(new MovieSimple(urlConnection1));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ glWindowHUD.setPosition(x2, y2);
+ glWindowHUD.setSize(w2, h2);
+ System.err.println("HUD: "+mPlayerHUD);
+ System.err.println("HUD: "+w2+"x"+h2);
+ glWindowHUD.addMouseListener(toFrontMouseListener);
+
+ viewGroup.post(new Runnable() {
+ public void run() {
+ final android.view.View androidView = ((AndroidWindow)glWindowHUD.getDelegatedWindow()).getAndroidView();
+ // addContentView(getWindow(), glWindowHUD, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight()));
+ viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight(), Gravity.TOP|Gravity.LEFT));
+ registerNEWTWindow(glWindowHUD);
+ animator.add(glWindowHUD);
+ glWindowHUD.setVisible(true);
+ } } );
+ return true;
} } );
}
animator.setUpdateFPSFrames(60, System.err);
+ // animator.setUpdateFPSFrames(-1, null);
animator.resetFPSCounter();
} catch (IOException e) {
e.printStackTrace();
@@ -199,7 +194,7 @@ public class MovieSimpleActivity extends NewtBaseActivity {
static URLConnection getResource(String path[], int off) {
URLConnection uc = null;
for(int i=off; null==uc && i<path.length; i++) {
- if(null != path[i]) {
+ if(null != path[i] && path[i].length()>0) {
uc = IOUtil.getResource(path[i], null);
Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uc));
}
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java
index 0fdd2297e..3ad462691 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java
@@ -34,17 +34,18 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties;
public class MovieSimpleActivityLauncher00a extends LauncherUtil.BaseActivityLauncher {
- static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity";
+ static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity0";
// 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.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.mplayer.nozoom", "true");
+ props.setProperty("jnlp.mplayer.hud", "false");
+ props.setProperty("jnlp.mplayer.hud.shared", "false");
+ // 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");
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java
index e52e065c7..a5370e90b 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00b.java
@@ -41,10 +41,11 @@ public class MovieSimpleActivityLauncher00b extends LauncherUtil.BaseActivityLau
@Override
public void init() {
final OrderedProperties props = getProperties();
- props.setProperty("jnlp.mplayer.normal", "true");
- 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.mplayer.nozoom", "false");
+ props.setProperty("jnlp.mplayer.hud", "false");
+ props.setProperty("jnlp.mplayer.hud.shared", "false");
+ // 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");
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
index 9e4823a04..ff3fadadf 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01a.java
@@ -41,10 +41,11 @@ public class MovieSimpleActivityLauncher01a extends LauncherUtil.BaseActivityLau
@Override
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.mplayer.nozoom", "true");
+ props.setProperty("jnlp.mplayer.hud", "true");
+ props.setProperty("jnlp.mplayer.hud.shared", "true");
+ // 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");
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java
index 81d121b0e..9992ac65a 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher01b.java
@@ -41,10 +41,11 @@ public class MovieSimpleActivityLauncher01b extends LauncherUtil.BaseActivityLau
@Override
public void init() {
final OrderedProperties props = getProperties();
- props.setProperty("jnlp.mplayer.normal", "false");
- props.setProperty("jnlp.mplayer.nozoom", "false");
- props.setProperty("jnlp.mplayer.shared", "true");
- props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v");
+ props.setProperty("jnlp.mplayer.nozoom", "false");
+ props.setProperty("jnlp.mplayer.hud", "true");
+ props.setProperty("jnlp.mplayer.hud.shared", "true");
+ // 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");
diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
index a907f063a..082cc6335 100644
--- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
+++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher02.java
@@ -41,10 +41,11 @@ public class MovieSimpleActivityLauncher02 extends LauncherUtil.BaseActivityLaun
@Override
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.mplayer.nozoom", "false");
+ props.setProperty("jnlp.mplayer.hud", "true");
+ props.setProperty("jnlp.mplayer.hud.shared", "false");
+ // 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");
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 dc1d97396..d32283473 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
@@ -56,7 +56,6 @@ 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;
@@ -80,7 +79,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
private long startTime;
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_GRADIENT_BOTTOM2TOP = 1<<1;
@@ -90,9 +88,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
public void setOrthoProjection(boolean v) { orthoProjection=v; }
public boolean getOrthoProjection() { return orthoProjection; }
- public void setTextureUnit(int u) { texUnit = u; }
- public int getTextureUnit() { return texUnit; }
-
public boolean hasEffect(int e) { return 0 != ( effects & e ) ; }
public void setEffects(int e) { effects = e; };
public void setTransparency(float alpha) {
@@ -149,29 +144,29 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
};
GLMediaPlayer mPlayer;
+ URLConnection stream = null;
boolean mPlayerExternal;
boolean mPlayerShared;
boolean mPlayerScaleOrig;
public MovieSimple(URLConnection stream) throws IOException {
mPlayerScaleOrig = false;
+ mPlayerShared = false;
mPlayerExternal = false;
mPlayer = GLMediaPlayerFactory.create();
mPlayer.addEventListener(this);
- mPlayer.initStream(stream);
- System.out.println("p0.1 "+mPlayer);
+ this.stream = stream;
+ System.out.println("pC.1 "+mPlayer);
}
- public MovieSimple(GLMediaPlayer mediaPlayer, boolean shared) throws IllegalStateException {
- if(!shared && GLMediaPlayer.State.UninitializedGL != mediaPlayer.getState()) {
- throw new IllegalStateException("Given GLMediaPlayer not in state "+GLMediaPlayer.State.UninitializedGL+": "+mediaPlayer);
- }
+ public MovieSimple(GLMediaPlayer sharedMediaPlayer) throws IllegalStateException {
mPlayerScaleOrig = false;
- mPlayerShared = shared;
+ mPlayerShared = true;
mPlayerExternal = true;
- mPlayer = mediaPlayer;
+ mPlayer = sharedMediaPlayer;
mPlayer.addEventListener(this);
- System.out.println("p0.2 shared "+mPlayerShared+", "+mPlayer);
+ this.stream = null;
+ System.out.println("pC.2 shared "+mPlayerShared+", "+mPlayer);
}
public GLMediaPlayer getGLMediaPlayer() { return mPlayer; }
@@ -181,13 +176,13 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
}
@Override
- public void attributesChanges(GLMediaPlayer mp, int event_mask) {
- System.out.println("attributesChanges: "+mp+", 0x"+Integer.toHexString(event_mask));
+ 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, TextureFrame frame) {
- // System.out.println("newFrameAvailable: "+mp+", "+frame);
+ public void newFrameAvailable(GLMediaPlayer mp, long when) {
+ // System.out.println("newFrameAvailable: "+mp+", when "+when);
}
public void start() {
@@ -240,13 +235,16 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
System.err.println(JoglVersion.getGLInfo(gl, null));
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);
if(!mPlayerShared) {
- mPlayer.initGL(gl);
+ mPlayer.initGLStream(gl, stream);
}
- System.out.println("p1 "+mPlayer);
+ System.out.println("p1 "+mPlayer+", shared "+mPlayerShared);
useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == mPlayer.getTextureTarget();
if(useExternalTexture && !gl.isExtensionAvailable("GL_OES_EGL_image_external")) {
throw new GLException("GL_OES_EGL_image_external requested but not available");
@@ -274,8 +272,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
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", texUnit))) {
+ if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", mPlayer.getTextureUnit()))) {
throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
}
@@ -320,7 +317,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
FloatBuffer verticeb = (FloatBuffer)vertices.getBuffer();
GLArrayData texcoord = interleaved.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
- TextureCoords tc = texFrame.getTexture().getImageTexCoords();
+ TextureCoords tc = mPlayer.getTextureCoords();
FloatBuffer texcoordb = (FloatBuffer)texcoord.getBuffer();
GLArrayData colors = interleaved.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
@@ -364,10 +361,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
}
interleaved.seal(gl, true);
- // OpenGL Render Settings
- // 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.glClearColor(0.3f, 0.3f, 0.3f, 0.3f);
gl.glEnable(GL2ES2.GL_DEPTH_TEST);
@@ -378,7 +372,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
if(null!=mPlayer) {
start();
- System.out.println("p1 "+mPlayer);
+ System.out.println("p2 "+mPlayer);
}
startTime = System.currentTimeMillis();
@@ -395,25 +389,25 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
if(null == mPlayer) { return; }
winWidth = width;
winHeight = height;
+
+ if(null != st) {
+ reshapePMV(width, height);
+ GL2ES2 gl = drawable.getGL().getGL2ES2();
+ st.useProgram(gl, true);
+ st.uniform(gl, pmvMatrixUniform);
+ st.useProgram(gl, false);
+ }
- reshapePMV(width, height);
-
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- st.useProgram(gl, true);
- st.uniform(gl, pmvMatrixUniform);
- st.useProgram(gl, false);
-
- System.out.println("p2 "+mPlayer);
+ System.out.println("pR "+mPlayer);
}
private void reshapePMV(int width, int height) {
pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
pmvMatrix.glLoadIdentity();
if(orthoProjection) {
- float fw = (float) width;
- float fh = (float) height;
- pmvMatrix.glOrthof(-fw/2f, fw/2f, -fh/2f, fh/2f, -1.0f, 1.0f);
+ final float fw = (float) width / 2f;
+ final float fh = (float) height/ 2f;
+ pmvMatrix.glOrthof(-fw, fw, -fh, fh, -1.0f, 1.0f);
nearPlaneNormalized = 0f;
} else {
pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1f, 10.0f);
@@ -430,6 +424,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
if(null == mPlayer) { return; }
stop();
+ System.out.println("pD.1 "+mPlayer);
GL2ES2 gl = drawable.getGL().getGL2ES2();
@@ -437,6 +432,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
if(!mPlayerExternal) {
mPlayer.destroy(gl);
}
+ System.out.println("pD.X "+mPlayer);
mPlayer=null;
pmvMatrixUniform = null;
pmvMatrix.destroy();
@@ -448,12 +444,12 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
public void display(GLAutoDrawable drawable) {
if(null == mPlayer) { return; }
- GL2ES2 gl = drawable.getGL().getGL2ES2();
-
- st.useProgram(gl, true);
+ 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);
@@ -465,27 +461,21 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener {
}
st.uniform(gl, pmvMatrixUniform);
- final Texture tex;
if(null!=mPlayer) {
final GLMediaPlayer.TextureFrame texFrame;
if(mPlayerShared) {
texFrame=mPlayer.getLastTexture();
} else {
- texFrame=mPlayer.getNextTexture();
+ texFrame=mPlayer.getNextTexture(gl, true);
+ }
+ if(null != texFrame) {
+ final Texture 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);
}
- tex = texFrame.getTexture();
- gl.glActiveTexture(GL.GL_TEXTURE0+texUnit);
- tex.enable(gl);
- tex.bind(gl);
- } else {
- tex = null;
- }
-
- // Draw a square
- gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
-
- if(null!=tex) {
- tex.disable(gl);
}
st.useProgram(gl, false);