Why 32-bit color EGL configurations fail with EGL_BAD_MATCH on Moto Droid?

Posted by Gilead on Stack Overflow See other posts from Stack Overflow or by Gilead
Published on 2010-05-31T23:30:52Z Indexed on 2010/05/31 23:33 UTC
Read the original article Hit count: 799

Filed under:
|
|

I'm trying to figure out why certain EGL configurations cause eglMakeCurrent() call to return EGL_BAD_MATCH on Motorola Droid running Android 2.1u1.

This is a full list of hardware-accelerated EGL configurations (those with EGL_CONFIG_CAVEAT == EGL_NONE) as there's a few others with EGL_CONFIG_CAVEAT == EGL_SLOW_CONFIG but those are backed by PixelFlinger 1.2 meaning they're using software renderer.

ID: 0 RGB: 8, 8, 8 Alpha: 8 Depth: 24 Stencil: 8 // BAD MATCH
ID: 1 RGB: 8, 8, 8 Alpha: 8 Depth:  0 Stencil: 0 // BAD MATCH
ID: 2 RGB: 8, 8, 8 Alpha: 8 Depth: 24 Stencil: 8 // BAD MATCH
ID: 3 RGB: 8, 8, 8 Alpha: 8 Depth: 24 Stencil: 8 // BAD MATCH
ID: 4 RGB: 8, 8, 8 Alpha: 8 Depth:  0 Stencil: 0 // BAD MATCH
ID: 5 RGB: 8, 8, 8 Alpha: 8 Depth: 24 Stencil: 8 // BAD MATCH
ID: 6 RGB: 5, 6, 5 Alpha: 0 Depth: 24 Stencil: 8
ID: 7 RGB: 5, 6, 5 Alpha: 0 Depth:  0 Stencil: 0
ID: 8 RGB: 5, 6, 5 Alpha: 0 Depth: 24 Stencil: 8

Clearly, all configurations with 32-bit color depth fail and all 16-bit ones are OK but:
1. Why?
2. WHY?! :)
3. How do I tell which ones would fail before actually trying to use them?

The code below is as simple as it can get. I put

if (v[0] == 6)
there to check different configs, normally they're chosen by half-clever config matcher :)


private void createSurface(SurfaceHolder holder) {
 egl = (EGL10)EGLContext.getEGL();
 eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
 egl.eglInitialize(eglDisplay, null);

 int[] numConfigs = new int[1];
 egl.eglChooseConfig(eglDisplay, new int[] { EGL10.EGL_NONE },
  null, 0, numConfigs);
 EGLConfig[] configs = new EGLConfig[numConfigs[0]];
 egl.eglChooseConfig(eglDisplay, new int[] { EGL10.EGL_NONE },
  configs, numConfigs[0], numConfigs);
 int[] v = new int[1];
 for (EGLConfig c : configs) {
  egl.eglGetConfigAttrib(eglDisplay, c, EGL10.EGL_CONFIG_ID, v);
  if (v[0] == 6) {
   eglConfig = c;
  }
 }

 eglContext = egl.eglCreateContext(eglDisplay, eglConfig,
  EGL10.EGL_NO_CONTEXT, null);
 if (eglContext == null || eglContext == EGL10.EGL_NO_CONTEXT) {
  throw new RuntimeException("Unable to create EGL context");
 }

 eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, holder, null);
 if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) {
  throw new RuntimeException("Unable to create EGL surface");
 }
 if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
  throw new RuntimeException("Unable to make EGL current");
 }

 gl = (GL10)eglContext.getGL();
}

© Stack Overflow or respective owner

Related posts about android

Related posts about opengl-es