Android : changed the way the glsurface's pixel format was chosen, allowing the surface to have a translucent background
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9507 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
ca3f1d941a
commit
67712589e2
@ -31,12 +31,10 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
* RGB565, 0 alpha, 16 depth, 0 stencil
|
* RGB565, 0 alpha, 16 depth, 0 stencil
|
||||||
*/
|
*/
|
||||||
FASTEST,
|
FASTEST,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RGB???, 0 alpha, >=16 depth, 0 stencil
|
* RGB???, 0 alpha, >=16 depth, 0 stencil
|
||||||
*/
|
*/
|
||||||
BEST,
|
BEST,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn off config chooser and use hardcoded
|
* Turn off config chooser and use hardcoded
|
||||||
* setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16,
|
* setEGLContextClientVersion(2); setEGLConfigChooser(5, 6, 5, 0, 16,
|
||||||
@ -106,31 +104,22 @@ public class AndroidConfigChooser implements EGLConfigChooser {
|
|||||||
|
|
||||||
private int getPixelFormat(EGLConfig conf, EGLDisplay display, EGL10 egl) {
|
private int getPixelFormat(EGLConfig conf, EGLDisplay display, EGL10 egl) {
|
||||||
int[] value = new int[1];
|
int[] value = new int[1];
|
||||||
int result = PixelFormat.RGB_565;
|
|
||||||
|
|
||||||
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_RED_SIZE, value);
|
//Android Pixel format is not very well documented.
|
||||||
if (value[0] == 8) {
|
//From what i gathered, the format is chosen automatically except for the alpha channel
|
||||||
result = PixelFormat.RGBA_8888;
|
//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);
|
egl.eglGetConfigAttrib(display, conf, EGL10.EGL_ALPHA_SIZE, value);
|
||||||
if (value[0] == 8)
|
if (value[0] >= 8) {
|
||||||
{
|
return PixelFormat.TRANSLUCENT;
|
||||||
result = PixelFormat.RGBA_8888;
|
|
||||||
}
|
}
|
||||||
else
|
if (value[0] >= 1) {
|
||||||
{
|
|
||||||
result = PixelFormat.RGB_888;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose) {
|
|
||||||
logger.log(Level.INFO, "Using PixelFormat {0}", result);
|
|
||||||
}
|
|
||||||
|
|
||||||
//return result; TODO Test pixelformat
|
|
||||||
return PixelFormat.TRANSPARENT;
|
return PixelFormat.TRANSPARENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return PixelFormat.OPAQUE;
|
||||||
|
}
|
||||||
|
|
||||||
private int getOpenGLVersion(EGLConfig conf, EGLDisplay display, EGL10 egl) {
|
private int getOpenGLVersion(EGLConfig conf, EGLDisplay display, EGL10 egl) {
|
||||||
int[] value = new int[1];
|
int[] value = new int[1];
|
||||||
int result = 1;
|
int result = 1;
|
||||||
|
@ -33,6 +33,7 @@ package com.jme3.system.android;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@ -104,6 +105,7 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
* @return GLSurfaceView The newly created view
|
* @return GLSurfaceView The newly created view
|
||||||
*/
|
*/
|
||||||
public GLSurfaceView createView(ConfigType configType, boolean eglConfigVerboseLogging) {
|
public GLSurfaceView createView(ConfigType configType, boolean eglConfigVerboseLogging) {
|
||||||
|
|
||||||
// Start to set up the view
|
// Start to set up the view
|
||||||
this.view = new AndroidInput(JmeAndroidSystem.getActivity());
|
this.view = new AndroidInput(JmeAndroidSystem.getActivity());
|
||||||
if (configType == ConfigType.LEGACY) {
|
if (configType == ConfigType.LEGACY) {
|
||||||
@ -152,6 +154,8 @@ public class OGLESContext implements JmeContext, GLSurfaceView.Renderer, SoftTex
|
|||||||
view.setFocusableInTouchMode(true);
|
view.setFocusableInTouchMode(true);
|
||||||
view.setFocusable(true);
|
view.setFocusable(true);
|
||||||
view.getHolder().setType(SurfaceHolder.SURFACE_TYPE_GPU);
|
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);
|
view.setRenderer(this);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user