diff --git a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java index fe2bfb118..506c99253 100644 --- a/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java +++ b/engine/src/android/com/jme3/system/android/AndroidConfigChooser.java @@ -31,12 +31,10 @@ public class AndroidConfigChooser implements EGLConfigChooser { * RGB565, 0 alpha, 16 depth, 0 stencil */ FASTEST, - /** * RGB???, 0 alpha, >=16 depth, 0 stencil */ BEST, - /** * Turn off config chooser and use hardcoded * setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16, @@ -106,29 +104,20 @@ public class AndroidConfigChooser implements EGLConfigChooser { private int getPixelFormat(EGLConfig conf, EGLDisplay display, EGL10 egl) { int[] value = new int[1]; - int result = PixelFormat.RGB_565; - - egl.eglGetConfigAttrib(display, conf, EGL10.EGL_RED_SIZE, value); - if (value[0] == 8) { - result = PixelFormat.RGBA_8888; - /* - egl.eglGetConfigAttrib(display, conf, EGL10.EGL_ALPHA_SIZE, value); - if (value[0] == 8) - { - result = PixelFormat.RGBA_8888; - } - else - { - result = PixelFormat.RGB_888; - }*/ + + //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 + //if it's 0 bit, the format is OPAQUE otherwise it's TRANSPARENT + egl.eglGetConfigAttrib(display, conf, EGL10.EGL_ALPHA_SIZE, value); + if (value[0] >= 8) { + return PixelFormat.TRANSLUCENT; } - - if (verbose) { - logger.log(Level.INFO, "Using PixelFormat {0}", result); + if (value[0] >= 1) { + return PixelFormat.TRANSPARENT; } - //return result; TODO Test pixelformat - return PixelFormat.TRANSPARENT; + return PixelFormat.OPAQUE; } private int getOpenGLVersion(EGLConfig conf, EGLDisplay display, EGL10 egl) { @@ -268,7 +257,7 @@ public class AndroidConfigChooser implements EGLConfigChooser { protected int mAlphaSize; protected int mDepthSize; protected int mStencilSize; - + public ComponentSizeChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize) { super(new int[]{ diff --git a/engine/src/android/com/jme3/system/android/OGLESContext.java b/engine/src/android/com/jme3/system/android/OGLESContext.java index 359531af3..8c8132e82 100644 --- a/engine/src/android/com/jme3/system/android/OGLESContext.java +++ b/engine/src/android/com/jme3/system/android/OGLESContext.java @@ -33,6 +33,7 @@ package com.jme3.system.android; import android.app.AlertDialog; import android.content.DialogInterface; +import android.graphics.PixelFormat; import android.opengl.GLSurfaceView; import android.text.InputType; import android.view.Gravity; @@ -104,6 +105,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex * @return GLSurfaceView The newly created view */ public GLSurfaceView createView(ConfigType configType, boolean eglConfigVerboseLogging) { + // Start to set up the view this.view = new AndroidInput(JmeAndroidSystem.getActivity()); if (configType == ConfigType.LEGACY) { @@ -152,8 +154,10 @@ 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); view.setRenderer(this); - + return view; }