diff options
Diffstat (limited to 'src/test/com')
11 files changed, 367 insertions, 81 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java index 1de095161..0a45f3c3b 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0a.java @@ -55,8 +55,8 @@ import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; import android.os.Bundle; import android.util.Log; -public class MovieCubeActivity0 extends NewtBaseActivity { - static String TAG = "MovieCubeActivity0"; +public class MovieCubeActivity0a extends NewtBaseActivity { + static String TAG = "MovieCubeActivity0a"; MouseAdapter showKeyboardMouseListener = new MouseAdapter() { @Override @@ -98,7 +98,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { glWindowMain.setVisible(true); glWindowMain.addMouseListener(showKeyboardMouseListener); - final MovieCube demoMain = new MovieCube(MovieCube.zoom_def, 0f, 0f); + final MovieCube demoMain = new MovieCube(MovieCube.zoom_def, 0f, 0f, false); final GLMediaPlayer mPlayer = demoMain.getGLMediaPlayer(); mPlayer.addEventListener(new GLMediaEventListener() { @Override diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java new file mode 100644 index 000000000..192b305f4 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0b.java @@ -0,0 +1,169 @@ +/** + * 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.HttpURLConnection; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URLConnection; +import java.util.Arrays; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +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 com.jogamp.opengl.util.av.GLMediaPlayer; +import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; +import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; + +import android.os.Bundle; +import android.util.Log; + +public class MovieCubeActivity0b extends NewtBaseActivity { + static String TAG = "MovieCubeActivity0a"; + + MouseAdapter showKeyboardMouseListener = new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if( e.getPointerCount() == 4 && e.getPressure(0, true) > 0.7f ) { + ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); + } + } + }; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + String[] streamLocs = new String[] { + System.getProperty("jnlp.media0_url2"), + System.getProperty("jnlp.media0_url1"), + System.getProperty("jnlp.media0_url0") }; + final URI streamLoc = getURI(streamLocs, 0, false); + if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } + + // also initializes JOGL + final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2()); + capsMain.setNumSamples(4); + capsMain.setSampleBuffers(true); + 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 anim = new Animator(); + + // Main + final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); + glWindowMain.setFullscreen(true); + setContentView(getWindow(), glWindowMain); + anim.add(glWindowMain); + glWindowMain.setVisible(true); + glWindowMain.addMouseListener(showKeyboardMouseListener); + + final MovieCube demoMain = new MovieCube(MovieCube.zoom_def, 0f, 0f, true); + final GLMediaPlayer mPlayer = demoMain.getGLMediaPlayer(); + mPlayer.addEventListener(new GLMediaEventListener() { + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { + } + + @Override + public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { + System.err.println("MovieCubeActivity0 AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieCubeActivity0 State: "+mp); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { + glWindowMain.addGLEventListener(demoMain); + anim.setUpdateFPSFrames(60, null); + anim.resetFPSCounter(); + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_PLAY & event_mask ) ) { + anim.resetFPSCounter(); + } + if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { + final StreamException se = mPlayer.getStreamException(); + if( null != se ) { + se.printStackTrace(); + } + getActivity().finish(); + } + } + }); + demoMain.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0); + } catch (IOException e) { + e.printStackTrace(); + } + + scrn.removeReference(); + + Log.d(TAG, "onCreate - X"); + } + + static URI getURI(String path[], int off, boolean checkAvail) { + URI uri = null; + for(int i=off; null==uri && i<path.length; i++) { + if(null != path[i] && path[i].length()>0) { + if( checkAvail ) { + final URLConnection uc = IOUtil.getResource(path[i], null); + if( null != uc ) { + try { + uri = uc.getURL().toURI(); + } catch (URISyntaxException e) { + uri = null; + } + if( uc instanceof HttpURLConnection ) { + ((HttpURLConnection)uc).disconnect(); + } + } + } else { + try { + uri = new URI(path[i]); + } catch (URISyntaxException e) { + uri = null; + } + } + Log.d(TAG, "Stream: <"+path[i]+">: "+(null!=uri)); + } + } + return uri; + } +} diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0a.java index 1e0d6067f..a850e42aa 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0a.java @@ -32,9 +32,9 @@ import java.util.List; import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; -public class MovieCubeActivityLauncher0 extends LauncherUtil.BaseActivityLauncher { +public class MovieCubeActivityLauncher0a extends LauncherUtil.BaseActivityLauncher { - static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0"; + static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0a"; static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0b.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0b.java new file mode 100644 index 000000000..8d8711319 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0b.java @@ -0,0 +1,88 @@ +/** + * 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 MovieCubeActivityLauncher0b extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0b"; + static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; + static String[] usr_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("jogamp.debug.Lock", "true"); + // props.setProperty("jogamp.debug.Lock.TraceLock", "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.GLMediaPlayer", "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> getSysPackages() { + return Arrays.asList(sys_pkgs); + } + + @Override + public List<String> getUsrPackages() { + return Arrays.asList(usr_pkgs); + } +} diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java index c4eea084a..5eab8a8e1 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java @@ -34,7 +34,7 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; public class MovieCubeActivityLauncher1a extends LauncherUtil.BaseActivityLauncher { - static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0"; + static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0a"; static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java index 26b61dd16..1e4c2c72f 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java @@ -34,7 +34,7 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; public class MovieCubeActivityLauncher1b extends LauncherUtil.BaseActivityLauncher { - static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0"; + static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0a"; static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index b5a9ce580..38c8b36d6 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -3,14 +3,14 @@ * * 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 @@ -20,7 +20,7 @@ * 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. @@ -57,7 +57,7 @@ import android.util.Log; public class MovieSimpleActivity0 extends NewtBaseActivity { static String TAG = "MovieSimpleActivity0"; - + MouseAdapter toFrontMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { Object src = e.getSource(); @@ -65,43 +65,45 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { ((Window)src).requestFocus(false); } } }; - + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - final String[] streamLocs = new String[] { + + final String[] streamLocs = new String[] { System.getProperty("jnlp.media0_url2"), System.getProperty("jnlp.media0_url1"), - System.getProperty("jnlp.media0_url0") }; + System.getProperty("jnlp.media0_url0") }; final URI streamLoc = getURI(streamLocs, 0, false); if(null == streamLoc) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } - + // also initializes JOGL final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2()); + capsMain.setNumSamples(4); + capsMain.setSampleBuffers(true); 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 Animator anim = new Animator(); - - // Main + + // Main final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); glWindowMain.setFullscreen(true); setContentView(getWindow(), glWindowMain); anim.add(glWindowMain); glWindowMain.setVisible(true); - + final MovieSimple demoMain = new MovieSimple(null); demoMain.setScaleOrig(true); final GLMediaPlayer mPlayer = demoMain.getGLMediaPlayer(); - mPlayer.addEventListener( new GLMediaPlayer.GLMediaEventListener() { + mPlayer.addEventListener( new GLMediaPlayer.GLMediaEventListener() { @Override public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } - + @Override public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { System.err.println("MovieSimpleActivity0 AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); @@ -114,19 +116,19 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { final StreamException se = mPlayer.getStreamException(); if( null != se ) { - se.printStackTrace(); + se.printStackTrace(); } getActivity().finish(); } } }); demoMain.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0); - + scrn.removeReference(); Log.d(TAG, "onCreate - X"); } - + static URI getURI(String path[], int off, boolean checkAvail) { URI uri = null; for(int i=off; null==uri && i<path.length; i++) { diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index e54300de5..5974c672b 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -3,14 +3,14 @@ * * 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 @@ -20,7 +20,7 @@ * 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. @@ -60,7 +60,7 @@ import android.view.Gravity; public class MovieSimpleActivity1 extends NewtBaseActivity { static String TAG = "MovieSimpleActivity1"; - + MouseAdapter toFrontMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { Object src = e.getSource(); @@ -68,24 +68,24 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { ((Window)src).requestFocus(false); } } }; - + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + final boolean mPlayerLocal = Boolean.valueOf(System.getProperty("jnlp.mplayer.local")); final boolean mPlayerNoZoom = Boolean.valueOf(System.getProperty("jnlp.mplayer.nozoom")); 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[] streamLocs = new String[] { + + String[] streamLocs = new String[] { System.getProperty("jnlp.media0_url2"), System.getProperty("jnlp.media0_url1"), - System.getProperty("jnlp.media0_url0") }; + System.getProperty("jnlp.media0_url0") }; final URI streamLoc0 = getURI(streamLocs, mPlayerLocal ? 2 : 0, false); if(null == streamLoc0) { throw new RuntimeException("no media reachable: "+Arrays.asList(streamLocs)); } - + final URI streamLoc1; { URI _streamLoc1 = null; @@ -96,25 +96,27 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { if(null == _streamLoc1) { _streamLoc1 = streamLoc0; } streamLoc1 = _streamLoc1; } - + setTransparencyTheme(); setFullscreenFeature(getWindow(), true); - + final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); getWindow().setContentView(viewGroup); - + // also initializes JOGL final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2()); + capsMain.setNumSamples(4); + capsMain.setSampleBuffers(true); capsMain.setBackgroundOpaque(!mPlayerHUD); // 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 Animator anim = new Animator(); - - // Main + + // Main final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); { final int padding = mPlayerHUD ? 32 : 0; @@ -127,18 +129,18 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { } anim.add(glWindowMain); glWindowMain.setVisible(true); - + final MovieSimple demoMain = new MovieSimple(null); - final GLMediaPlayer mPlayerMain = demoMain.getGLMediaPlayer(); + final GLMediaPlayer mPlayerMain = demoMain.getGLMediaPlayer(); if(mPlayerHUD) { demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); demoMain.setTransparency(0.9f); } demoMain.setScaleOrig(mPlayerNoZoom); - mPlayerMain.addEventListener( new GLMediaPlayer.GLMediaEventListener() { + mPlayerMain.addEventListener( new GLMediaPlayer.GLMediaEventListener() { @Override public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } - + @Override public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { System.err.println("MovieSimpleActivity1 AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); @@ -151,17 +153,19 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { final StreamException se = mPlayerMain.getStreamException(); if( null != se ) { - se.printStackTrace(); + se.printStackTrace(); } getActivity().finish(); } } }); demoMain.initStream(streamLoc0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0); - + if(mPlayerHUD) { - final GLMediaPlayer mPlayerShared = mPlayerSharedHUD ? mPlayerMain : null; + final GLMediaPlayer mPlayerShared = mPlayerSharedHUD ? mPlayerMain : null; final GLCapabilities capsHUD = new GLCapabilities(GLProfile.getGL2ES2()); + capsHUD.setNumSamples(4); + capsHUD.setSampleBuffers(true); capsHUD.setBackgroundOpaque(false); final GLWindow glWindowHUD = GLWindow.create(scrn, capsHUD); glWindowMain.invoke(false, new GLRunnable() { @@ -186,10 +190,10 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { demoHUD = new MovieSimple(null); mPlayerSub = demoHUD.getGLMediaPlayer(); } - mPlayerSub.addEventListener( new GLMediaPlayer.GLMediaEventListener() { + mPlayerSub.addEventListener( new GLMediaPlayer.GLMediaEventListener() { @Override public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } - + @Override public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { @@ -198,38 +202,38 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { final StreamException se = mPlayerMain.getStreamException(); if( null != se ) { - se.printStackTrace(); + se.printStackTrace(); } getActivity().finish(); } } }); demoHUD.initStream(streamLoc1, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0); - + glWindowHUD.setPosition(x2, y2); glWindowHUD.setSize(w2, h2); System.err.println("HUD: "+mPlayerHUD); - System.err.println("HUD: "+w2+"x"+h2); - glWindowHUD.addMouseListener(toFrontMouseListener); + System.err.println("HUD: "+w2+"x"+h2); + glWindowHUD.addMouseListener(toFrontMouseListener); viewGroup.post(new Runnable() { public void run() { final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)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); + registerNEWTWindow(glWindowHUD); anim.add(glWindowHUD); glWindowHUD.setVisible(true); } } ); return true; } } ); } - + scrn.removeReference(); Log.d(TAG, "onCreate - X"); } - + static URI getURI(String path[], int off, boolean checkAvail) { URI uri = null; for(int i=off; null==uri && i<path.length; i++) { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index b6936dc0e..f9becfaed 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -53,12 +53,13 @@ public class GPUUISceneGLListener0A implements GLEventListener { final float relRight = 2f/6f; final float relLeft = 1f/6f; - final float buttonXSize = 84f; - final float buttonYSize = buttonXSize/2.5f; + /** Proportional Button Size to Window Height, per-vertical-pixels [PVP] */ + final float buttonYSizePVP = 0.084f; + final float buttonXSizePVP = 0.105f; final float fontSizePt = 10f; - /** Proportional Window Height Font Size for Main Text, per-vertical-pixels [PVP] */ + /** Proportional Font Size to Window Height for Main Text, per-vertical-pixels [PVP] */ final float fontSizeFixedPVP = 0.046f; - /** Proportional Window Height Font Size for FPS Status Line, per-vertical-pixels [PVP] */ + /** Proportional Font Size to Window Height for FPS Status Line, per-vertical-pixels [PVP] */ final float fontSizeFpsPVP = 0.038f; float dpiH = 96; @@ -141,10 +142,13 @@ public class GPUUISceneGLListener0A implements GLEventListener { } } - private void initButtons(final GL gl, final RegionRenderer renderer) { + private void initButtons(final GL gl, final int width, final int height, final RegionRenderer renderer) { final boolean pass2Mode = 0 != ( renderer.getRenderModes() & ( Region.VBAA_RENDERING_BIT | Region.MSAA_RENDERING_BIT ) ) ; buttons.clear(); + final float buttonXSize = buttonXSizePVP * width; + final float buttonYSize = buttonYSizePVP * height; + System.err.println("Button Size: "+buttonXSizePVP+" x "+buttonYSizePVP+" * "+width+" x "+height+" -> "+buttonXSize+" x "+buttonYSize); final float xstart = 0f; final float ystart = 0f; final float diffX = 1.2f * buttonXSize; @@ -545,7 +549,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { crossHairCtr.setEnabled(true); crossHairCtr.translate(0f, 0f, -1f); - initButtons(gl, renderer); + initButtons(gl, drawable.getWidth(), drawable.getHeight(), renderer); for(int i=0; i<buttons.size(); i++) { sceneUIController.addShape(buttons.get(i)); } @@ -622,7 +626,8 @@ public class GPUUISceneGLListener0A implements GLEventListener { final String modeS = Region.getRenderModeString(renderer.getRenderModes()); final String text; if( null == actionText ) { - text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize %.1f, %s-samples %d, td %4.1f, blend %b, alpha-bits %d, msaa-bits %d", + final String timePrec = gl.isGLES() ? "4.0" : "4.1"; + text = String.format("%03.1f/%03.1f fps, v-sync %d, fontSize %.1f, %s-samples %d, td %"+timePrec+"f, blend %b, alpha-bits %d, msaa-bits %d", lfps, tfps, gl.getSwapInterval(), fontSizeFixedPVP, modeS, sceneUIController.getSampleCount(), td, renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED), drawable.getChosenGLCapabilities().getAlphaBits(), 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 index 5ee0fc058..dcdf26165 100644 --- 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 @@ -33,6 +33,7 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; @@ -99,7 +100,7 @@ public class MovieCube implements GLEventListener { * </p> */ public MovieCube() throws IOException, URISyntaxException { - this(zoom_def, 0f, 0f); + this(zoom_def, 0f, 0f, true); mPlayer.addEventListener(new GLMediaEventListener() { @Override @@ -136,11 +137,14 @@ public class MovieCube implements GLEventListener { } } - /** Custom constructor, user needs to issue {@link #initStream(URI, int, int, int)} afterwards. */ - public MovieCube(float zoom0, float rotx, float roty) throws IOException { + /** + * Custom constructor, user needs to issue {@link #initStream(URI, int, int, int)} afterwards. + */ + public MovieCube(float zoom0, float rotx, float roty, boolean showText) throws IOException { this.zoom0 = zoom0; this.rotx = rotx; this.roty = roty; + this.showText = showText; mPlayer = GLMediaPlayerFactory.createDefault(); } @@ -166,9 +170,9 @@ public class MovieCube implements GLEventListener { private final GLRegion regionFPS; private float pixelSize, underlineSize; - InfoTextRendererGLELBase() { + InfoTextRendererGLELBase(final int rmode) { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO - super(Region.VBAA_RENDERING_BIT, MovieCube.this.textSampleCount); + super(rmode, MovieCube.this.textSampleCount); // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! // this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); regionFPS = GLRegion.create(usrRenderModes); @@ -229,7 +233,9 @@ public class MovieCube implements GLEventListener { "; underlineSize "+underlineSize+" "+(pixelScale*underlineSize)+ "; yoff "+yoff1+", yoff2 "+yoff2); */ - final String text1 = String.format("%03.1f/%03.1f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, v-sync %d", + final GL gl = drawable.getGL(); + final String ptsPrec = gl.isGLES() ? "3.0" : "3.1"; + final String text1 = String.format("%0"+ptsPrec+"f/%0"+ptsPrec+"f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, v-sync %d", pts, mPlayer.getDuration() / 1000f, mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), aspect, mPlayer.getFramerate(), lfps, tfps, swapIntervalSet); @@ -239,14 +245,15 @@ public class MovieCube implements GLEventListener { mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec()); final String text4 = mPlayer.getURI().getRawPath(); if( displayOSD && null != renderer ) { - drawable.getGL().glClearColor(1.0f, 1.0f, 1.0f, 0.0f); + gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); renderString(drawable, font, pixelSize, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, regionFPS); // no-cache renderString(drawable, font, pixelSize, text2, 1 /* col */, 0 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); renderString(drawable, font, pixelSize, text3, 1 /* col */, 1 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); renderString(drawable, font, pixelSize, text4, 1 /* col */, 2 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); } } }; - private final InfoTextRendererGLELBase textRendererGLEL = new InfoTextRendererGLELBase(); + private InfoTextRendererGLELBase textRendererGLEL = null; + final boolean showText; private boolean displayOSD = true; private final KeyListener keyAction = new KeyAdapter() { @@ -370,7 +377,11 @@ public class MovieCube implements GLEventListener { added = true; } else { added = false; } System.err.println("MC.init: kl-added "+added+", "+drawable.getClass().getName()); - drawable.addGLEventListener(textRendererGLEL); + + if( showText ) { + textRendererGLEL = new InfoTextRendererGLELBase(drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT); + drawable.addGLEventListener(textRendererGLEL); + } } @Override @@ -382,7 +393,10 @@ public class MovieCube implements GLEventListener { @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" MovieCube.dispose ... "); - drawable.disposeGLEventListener(textRendererGLEL, true); + if( null != textRendererGLEL ) { + drawable.disposeGLEventListener(textRendererGLEL, true); + textRendererGLEL = null; + } disposeImpl(drawable, true); } @@ -507,7 +521,7 @@ public class MovieCube implements GLEventListener { System.err.println("forceGLDef "+forceGLDef); System.err.println("swapInterval "+swapInterval); - final MovieCube mc = new MovieCube(zoom_def, 0f, 0f); + final MovieCube mc = new MovieCube(zoom_def, 0f, 0f, true); mc.setSwapInterval(swapInterval); final GLProfile glp; 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 f0e9c4bde..c5160ffb1 100644 --- 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 @@ -139,9 +139,9 @@ public class MovieSimple implements GLEventListener { private final float fontSize = 10f; private final GLRegion regionFPS; - InfoTextRendererGLELBase() { + InfoTextRendererGLELBase(int rmode) { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO - super(Region.VBAA_RENDERING_BIT, textSampleCount); + super(rmode, textSampleCount); // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! // this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); regionFPS = GLRegion.create(usrRenderModes); @@ -178,7 +178,9 @@ public class MovieSimple implements GLEventListener { final float aspect = (float)mPlayer.getWidth() / (float)mPlayer.getHeight(); - final String text1 = String.format("%03.1f/%03.1f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, v-sync %d", + final GL gl = drawable.getGL(); + final String ptsPrec = gl.isGLES() ? "3.0" : "3.1"; + final String text1 = String.format("%0"+ptsPrec+"f/%0"+ptsPrec+"f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, v-sync %d", pts, mPlayer.getDuration() / 1000f, mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), aspect, mPlayer.getFramerate(), lfps, tfps, swapIntervalSet); @@ -196,7 +198,7 @@ public class MovieSimple implements GLEventListener { renderString(drawable, font, pixelSize, text4, 1 /* col */, -2 /* row */, 0, height, -1, true); } } }; - private final InfoTextRendererGLELBase textRendererGLEL = new InfoTextRendererGLELBase(); + private InfoTextRendererGLELBase textRendererGLEL = null; private boolean displayOSD = true; private final MouseListener mouseAction = new MouseAdapter() { @@ -593,6 +595,7 @@ public class MovieSimple implements GLEventListener { winWidth = window.getWidth(); winHeight = window.getHeight(); } + textRendererGLEL = new InfoTextRendererGLELBase(drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT); drawable.addGLEventListener(textRendererGLEL); } @@ -689,6 +692,7 @@ public class MovieSimple implements GLEventListener { @Override public void dispose(GLAutoDrawable drawable) { drawable.disposeGLEventListener(textRendererGLEL, true); + textRendererGLEL = null; disposeImpl(drawable, true); } |