diff --git a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java index 506c99253..91ed2b6c6 100644 --- a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java +++ b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java @@ -40,8 +40,11 @@ public class AndroidConfigChooser implements EGLConfigChooser { * setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16, * 0); */ - LEGACY - } + LEGACY, + /** + * RGB???, 8 alpha, >=16 depth, 0 stencil + */ + BEST_TRANSLUCENT,} public AndroidConfigChooser(ConfigType type) { this.type = type; @@ -65,27 +68,32 @@ public class AndroidConfigChooser implements EGLConfigChooser { * @return true if successfull, false if no config was found */ public boolean findConfig(EGL10 egl, EGLDisplay display) { - if (type == ConfigType.BEST) { - ComponentSizeChooser compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0); - choosenConfig = compChooser.chooseConfig(egl, display); - if (choosenConfig == null) { + ComponentSizeChooser compChooser = null; + switch (type) { + case BEST: compChooser = new ComponentSizeChooser(8, 8, 8, 0, 32, 0); choosenConfig = compChooser.chooseConfig(egl, display); + if (choosenConfig == null) { + compChooser = new ComponentSizeChooser(8, 8, 8, 0, 16, 0); + choosenConfig = compChooser.chooseConfig(egl, display); + } + logger.info("JME3 using best EGL configuration available here: "); + break; + case BEST_TRANSLUCENT: + compChooser = new ComponentSizeChooser(8, 8, 8, 8, 32, 0); + choosenConfig = compChooser.chooseConfig(egl, display); if (choosenConfig == null) { compChooser = new ComponentSizeChooser(8, 8, 8, 8, 16, 0); choosenConfig = compChooser.chooseConfig(egl, display); - if (choosenConfig == null) { - compChooser = new ComponentSizeChooser(8, 8, 8, 0, 16, 0); - choosenConfig = compChooser.chooseConfig(egl, display); - } } - } + logger.info("JME3 using best EGL configuration available here with translucent pixels: "); + break; + case FASTEST: + compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0); + choosenConfig = compChooser.chooseConfig(egl, display); + logger.info("JME3 using fastest EGL configuration available here: "); + break; - logger.info("JME3 using best EGL configuration available here: "); - } else { - ComponentSizeChooser compChooser = new ComponentSizeChooser(5, 6, 5, 0, 16, 0); - choosenConfig = compChooser.chooseConfig(egl, display); - logger.info("JME3 using fastest EGL configuration available here: "); } if (choosenConfig != null) { @@ -104,7 +112,7 @@ public class AndroidConfigChooser implements EGLConfigChooser { private int getPixelFormat(EGLConfig conf, EGLDisplay display, EGL10 egl) { int[] value = new int[1]; - + //Android Pixel format is not very well documented. //From what i gathered, the format is chosen automatically except for the alpha channel //if the alpha channel has 8 bit or more, e set the pixel format to Transluscent, as it allow transparent view background diff --git a/engine/src/android/com/jme3/system/android/OGLESContext.java b/engine/src/android/com/jme3/system/android/OGLESContext.java index 8c8132e82..2d9a0b10f 100644 --- a/engine/src/android/com/jme3/system/android/OGLESContext.java +++ b/engine/src/android/com/jme3/system/android/OGLESContext.java @@ -154,10 +154,12 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex view.setFocusableInTouchMode(true); view.setFocusable(true); view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU); - //This is important to allow the GL surface to have a translucent background - view.setZOrderOnTop(true); + if (configType == ConfigType.BEST_TRANSLUCENT) { + //This is important to allow the GL surface to have a translucent background + view.setZOrderOnTop(true); + } view.setRenderer(this); - + return view; } @@ -184,6 +186,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex // Setup unhandled Exception Handler Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + public void uncaughtException(Thread thread, Throwable thrown) { listener.handleError("Exception thrown in " + thread.toString(), thrown); } @@ -378,6 +381,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex new Object[]{title, initialValue}); JmeAndroidSystem.getActivity().runOnUiThread(new Runnable() { + @Override public void run() {