Android : Pixel Format again. Transparent or Translucent pixel format should not be the deault setting as they drain a substential amount of fps and that most of the games will have an opaque background.

There is now a new ogles configType called BEST_TRANSLUCENT if users really want a transparent background.
The BEST or FASTEST confing are now both OPAQUE, this gives a nice boost to the BEST configuration.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9508 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 67712589e2
commit 4e987ae63e
  1. 42
      engine/src/android/com/jme3/system/android/AndroidConfigChooser.java
  2. 10
      engine/src/android/com/jme3/system/android/OGLESContext.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

@ -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() {

Loading…
Cancel
Save