diff options
10 files changed, 81 insertions, 67 deletions
diff --git a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java index b79be888f..3120fc73e 100644 --- a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java +++ b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java @@ -64,8 +64,8 @@ public abstract class NEWTLauncherActivity extends Activity { // System.setProperty("jogl.debug", "all"); // System.setProperty("jogl.debug.GLProfile", "true"); - // System.setProperty("jogl.debug.GLDrawable", "true"); - // System.setProperty("jogl.debug.GLContext", "true"); + System.setProperty("jogl.debug.GLDrawable", "true"); + System.setProperty("jogl.debug.GLContext", "true"); System.setProperty("jogl.debug.GLSLCode", "true"); System.setProperty("jogl.debug.CapabilitiesChooser", "true"); @@ -107,11 +107,6 @@ public abstract class NEWTLauncherActivity extends Activity { throw e; } - // Make window fullscreen - requestWindowFeature(Window.FEATURE_NO_TITLE); - getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, - WindowManager.LayoutParams.FLAG_FULLSCREEN); - callMethod(activityObject, mSetIsInvokedByExternalActivity, this); callMethod(activityObject, mOnCreate, savedInstanceState); diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index b9301b05a..c5019bf63 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -57,6 +57,8 @@ import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback2; import android.view.SurfaceView; import android.view.View; +import android.view.Window; +import android.view.WindowManager; public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { static { @@ -113,24 +115,19 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { public static int getFormat(CapabilitiesImmutable rCaps) { int fmt = PixelFormat.UNKNOWN; - /* - if(rCaps.getAlphaBits()==0) { - fmt = PixelFormat.RGB_565; - } else { - fmt = PixelFormat.RGBA_5551; - } */ if(rCaps.getRedBits()<=5 && rCaps.getGreenBits()<=6 && rCaps.getBlueBits()<=5 && rCaps.getAlphaBits()==0) { fmt = PixelFormat.RGB_565; - } else - if(rCaps.getRedBits()<=5 && + } + /* else if(rCaps.getRedBits()<=5 && rCaps.getGreenBits()<=5 && rCaps.getBlueBits()<=5 && rCaps.getAlphaBits()==1) { fmt = PixelFormat.RGBA_5551; // FIXME: Supported ? - } else { + } */ + else { fmt = PixelFormat.RGBA_8888; } Log.d(MD.TAG, "getFormat: requested: "+rCaps); @@ -159,28 +156,32 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { @Override protected void instantiationFinished() { - nsv = new MSurfaceView(jogamp.common.os.android.StaticContext.getContext()); + androidView = new MSurfaceView(jogamp.common.os.android.StaticContext.getContext()); AndroidEvents ae = new AndroidEvents(); - nsv.setOnTouchListener(ae); - nsv.setClickable(false); + androidView.setOnTouchListener(ae); + androidView.setClickable(false); // nsv.setOnKeyListener(ae); - SurfaceHolder sh = nsv.getHolder(); + SurfaceHolder sh = androidView.getHolder(); sh.addCallback(this); // setFormat is done by SurfaceView in SDK 2.3 and newer. Uncomment // this statement if back-porting to 2.2 or older: // sh.setFormat(PixelFormat.RGB_565); - // sh.setFormat(getPixelFormat(requestedCaps)); // n/a at this moment // sh.setFormat(PixelFormat.RGBA_5551); // sh.setFormat(PixelFormat.RGBA_8888); + sh.setFormat(getFormat(getRequestedCapabilities())); // setType is not needed for SDK 2.0 or newer. Uncomment this // statement if back-porting this code to older SDKs. - sh.setFormat(getFormat(getRequestedCapabilities())); // sh.setType(SurfaceHolder.SURFACE_TYPE_GPU); // sh.setType(SurfaceHolder.SURFACE_TYPE_NORMAL); } - - public SurfaceView getView() { return nsv; } + public SurfaceView getAndroidView() { return androidView; } + + public void setAndroidWindow(android.view.Window window) { + androidWindow = window; + androidSetupFullscreen(); + } + public android.view.Window getAndroidWindow() { return androidWindow; } @Override protected boolean canCreateNativeImpl() { @@ -202,12 +203,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { } final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); - // final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(eglDevice) - // .chooseGraphicsConfiguration(capsByFormat, getRequestedCapabilities(), capabilitiesChooser, getScreen().getGraphicsScreen()); final EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( capsByFormat, (GLCapabilitiesImmutable) getRequestedCapabilities(), - (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), - format); // JAU FIXME: filter out by android visualID ?? + (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), format); if (eglConfig == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } @@ -219,8 +217,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { ", error 0x"+Integer.toHexString(EGL.eglGetError())); } Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID.get(0))); - // JAU FIXME - setSurfaceVisualID0(surfaceHandle, nativeVisualID.get(0)); + if(nativeVisualID.get(0)>0) { + setSurfaceVisualID0(surfaceHandle, nativeVisualID.get(0)); + } eglSurface = EGL.eglCreateWindowSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null); if (EGL.EGL_NO_SURFACE==eglSurface) { @@ -248,14 +247,18 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { protected void requestFocusImpl(boolean reparented) { } + protected void androidSetupFullscreen() { + if( null != androidWindow && isFullscreen() ) { + androidWindow.requestFeature(Window.FEATURE_NO_TITLE); + androidWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + } + } + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(0!=getWindowHandle()) { - if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { - System.err.println("reconfigureWindowImpl.setFullscreen n/a"); - return false; - } - } + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + System.err.println("reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); + return false; } if(width>0 || height>0) { if(0!=getWindowHandle()) { @@ -273,7 +276,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { return true; } - /*** + /** Canvas cLock = null; @Override @@ -347,6 +350,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { surfaceHandle = getSurfaceHandle0(surface); acquire0(surfaceHandle); format = getSurfaceVisualID0(surfaceHandle); + capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); if(0>x || 0>y) { x = 0; y = 0; @@ -358,10 +362,6 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+ ", "+x+"/"+y+" "+width+"x"+height); - capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); - // capsByFormat = (GLCapabilitiesImmutable) fixCapsAlpha(getRequestedCapabilities()); - // capsByFormat = (GLCapabilitiesImmutable) getRequestedCapabilities(); - if(isVisible()) { setVisible(true); } @@ -379,17 +379,17 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { } - private MSurfaceView nsv; + private MSurfaceView androidView; + private android.view.Window androidWindow; private int format; // stored current PixelFormat private GLCapabilitiesImmutable capsByFormat; // fixed requestedCaps by PixelFormat private Surface surface = null; private volatile long surfaceHandle = 0; private long eglSurface = 0; - static class MSurfaceView extends SurfaceView { + class MSurfaceView extends SurfaceView { public MSurfaceView (Context ctx) { - super(ctx); - + super(ctx); } } //---------------------------------------------------------------------- @@ -403,5 +403,4 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { protected static native int getHeight0(long surfaceHandle); protected static native void acquire0(long surfaceHandle); protected static native void release0(long surfaceHandle); - } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 9a2a0ea2c..5e5b90770 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -40,7 +40,7 @@ import android.os.Bundle; import android.util.Log; public class NewtBaseActivity extends Activity { - AndroidWindow window = null; + AndroidWindow newtWindow = null; Animator animator = null; boolean isInvokedByExternalActivity = false; @@ -54,25 +54,39 @@ public class NewtBaseActivity extends Activity { return null != extActivity; } - public void setContentView(Window window) { - if(window instanceof GLWindow) { - window = ((GLWindow)window).getWindow(); + public Activity getActivity() { + if(isInvokedByExternalActivity) { + return extActivity; + } else { + return this; + } + } + + public void setContentView(android.view.Window androidWindow, Window newtWindow) { + if(newtWindow instanceof GLWindow) { + newtWindow = ((GLWindow)newtWindow).getWindow(); } - if(window instanceof AndroidWindow) { - this.window = (AndroidWindow)window; + if(newtWindow instanceof AndroidWindow) { + this.newtWindow = (AndroidWindow)newtWindow; + this.newtWindow.setAndroidWindow(androidWindow); if(isInvokedByExternalActivity) { - extActivity.setContentView(this.window.getView()); + extActivity.setContentView(this.newtWindow.getAndroidView()); } else { - super.setContentView(this.window.getView()); + super.setContentView(this.newtWindow.getAndroidView()); } } else { - throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+window.getClass()); + throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass()); } } public void setAnimator(Animator animator) { this.animator = animator; } + + @Override + public android.view.Window getWindow() { + return getActivity().getWindow(); + } @Override public void onCreate(Bundle savedInstanceState) { @@ -83,7 +97,8 @@ public class NewtBaseActivity extends Activity { jogamp.common.os.android.StaticContext.setContext(getApplicationContext()); } else { jogamp.common.os.android.StaticContext.setContext(extActivity.getApplicationContext()); - } + } + extActivity.getWindow(); // init GLProfile GLProfile.initSingleton(true); @@ -142,9 +157,9 @@ public class NewtBaseActivity extends Activity { animator.stop(); animator = null; } - if(null != window) { - window.destroy(); - window = null; + if(null != newtWindow) { + newtWindow.destroy(); + newtWindow = null; } if(!isInvokedByExternalActivity) { super.onDestroy(); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java index b36f567bb..442400868 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java @@ -57,7 +57,8 @@ public class NEWTElektronActivity extends NewtBaseActivity { // caps.setSampleBuffers(true); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new ElektronenMultiplizierer()); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java index 897df89cd..bc4e7d394 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java @@ -54,7 +54,7 @@ public class NEWTGearsES1Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES1(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index b19c12d4a..164857760 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -54,7 +54,8 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES2(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java index 99de90f2a..83f35879b 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java @@ -57,7 +57,8 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity { caps.setSampleBuffers(true); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(0)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java index c627ce725..17924d43d 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java @@ -58,7 +58,8 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity { caps.setSampleBuffers(true); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(Region.VBAA_RENDERING_BIT)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java index bf5fcce49..6fc3a46d6 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java @@ -54,7 +54,7 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new RedSquareES1(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java index fcffc5244..e9ef981b8 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java @@ -54,7 +54,8 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity { GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); - setContentView(glWindow); + glWindow.setFullscreen(true); + setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new RedSquareES2(1)); glWindow.getWindow().getScreen().addScreenModeListener(new ScreenModeListener() { |