mSurfaceView.setEGLConfigChooser(
new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
int[] attributes=new int[]{
EGL10.EGL_DEPTH_SIZE, 16,
EGL10.EGL_STENCIL_SIZE, 0,
//EGL10.EGL_RED_SIZE, 5,
//EGL10.EGL_GREEN_SIZE, 6,
//EGL10.EGL_BLUE_SIZE, 5,
//EGL10.EGL_ALPHA_SIZE, 0,
EGL10.EGL_NONE
};
int[] numConfig = new int[1];
egl.eglChooseConfig(display, attributes, null, 0, numConfig);
EGLConfig[] configs=new EGLConfig[numConfig[0]];
int[] result=new int[1];
egl.eglChooseConfig(display, attributes, configs, numConfig[0], result);
Log.i(TAG, "result[0] = " + result[0]);
listConfig(egl, display, configs);
return configs[6];
}
});
...
...
...
private int getConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute) {
int[] value = new int[1];
return egl.eglGetConfigAttrib(display, config,
attribute, value)? value[0] : 0;
}
private void listConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
Log.i(TAG, "Config List {");
for (EGLConfig config : configs) {
int d, s, r, g, b, a;
// Expand on this logic to dump other attributes
d = getConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE);
s = getConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE);
r = getConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE);
g = getConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE);
b = getConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE);
a = getConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE);
Log.i(TAG, " <d,s,r,g,b,a> = <" + d + "," + s + "," +
r + "," + g + "," + b + "," + a + ">");
}
Log.i(TAG, "}");
}