I am implementing my own EGLConfigChooserto go on setEGLConfigChooser()to select the best available configuration for the current device according to the needs that I have for the application.
To be more specific, I request all available configurations and select the one that has the largest depth buffer size (and between those that have the same depth buffer size, I want the one that has the largest color depth), the code wall follows
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
{
int[] num_conf = new int[1];
egl.eglGetConfigs(display, null, 0, num_conf);
int configurations = num_conf[0];
EGLConfig[] conf = new EGLConfig[configurations];
egl.eglGetConfigs(display, conf, configurations, num_conf);
EGLConfig result = null;
for(int i = 0; i < configurations; i++)
{
Log.v("EGLConfigChooser", "Configuration #" + i );
print(egl, display, conf[i]);
result = better(result, conf[i], egl, display);
}
Log.v("EGLConfigChooser", "Chosen EGLConfig:");
print(egl, display, result);
return result;
}
private EGLConfig better(EGLConfig a, EGLConfig b, EGL10 egl, EGLDisplay display)
{
if(a == null) return b;
EGLConfig result = null;
int[] value = new int[1];
egl.eglGetConfigAttrib(display, a, EGL10.EGL_DEPTH_SIZE, value);
int depthA = value[0];
egl.eglGetConfigAttrib(display, b, EGL10.EGL_DEPTH_SIZE, value);
int depthB = value[0];
if(depthA > depthB)
result = a;
else if(depthA < depthB)
result = b;
else
{
egl.eglGetConfigAttrib(display, a, EGL10.EGL_RED_SIZE, value);
int redA = value[0];
egl.eglGetConfigAttrib(display, b, EGL10.EGL_RED_SIZE, value);
int redB = value[0];
if(redA > redB)
result = a;
else if(redA < redB)
result = b;
else
{
result = a;
}
}
return result;
}
(The print method prints the EGLConfig values ββin Logger)
Now it works fine, it selects the following configuration:
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): Chosen EGLConfig:
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_RED_SIZE = 8
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_BLUE_SIZE = 8
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_GREEN_SIZE = 8
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_ALPHA_SIZE = 8
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_DEPTH_SIZE = 24
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_ALPHA_FORMAT = 24
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_ALPHA_MASK_SIZE = 0
01-30 18:57:04.424: VERBOSE/EGLConfigChooser(1093): EGL_STENCIL_SIZE = 8
, ( ), , , , , , (?!!).
, eglGetConfigs , ? - - ? , ( http://brandnewreality.com/blog/android-egl-querying-your-gl-driver)
.