title: EGL working on Linux but not on Android
body: <p>I have EGL/GLES 2.0 code, which I try to run on Linux (via Mesa) and Android (iOS to come). On Linux it works fine and renders like expected.
  Running on Android (Phone, tablet and emulator - all 4.01) it passes fine but displays nothing (screen stays black). 
  The code is 99% the same for all 3 - with some special handling for Android.
  Following my EGL attributes:</p>
  
  <pre><code>EGLint attribList[] =
  {
      EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
      EGL_RED_SIZE,       8,
      EGL_GREEN_SIZE,     8,
      EGL_BLUE_SIZE,      8,
      //EGL_ALPHA_SIZE,     (flags &amp; ES_WINDOW_ALPHA) ? 8 : EGL_DONT_CARE,
      //EGL_DEPTH_SIZE,     (flags &amp; ES_WINDOW_DEPTH) ? 8 : EGL_DONT_CARE,
      //EGL_STENCIL_SIZE,   (flags &amp; ES_WINDOW_STENCIL) ? 8 : EGL_DONT_CARE,
      EGL_SAMPLE_BUFFERS, (flags &amp; ES_WINDOW_MULTISAMPLE) ? 1 : 0,
      // For Android this is extremely important - eglCreateContext will fail without it
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
      EGL_NONE, EGL_NONE
  };
  </code></pre>
  
  <p>Following the EGL creation code:</p>
  
  <pre><code>EGLint numConfigs;
  EGLint majorVersion;
  EGLint minorVersion;
  EGLDisplay display;
  EGLContext context;
  EGLSurface surface;
  EGLConfig config;
  EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
  
  // Get Display
  display = eglGetDisplay((EGLNativeDisplayType)x_display);
  if ( display == EGL_NO_DISPLAY )
  {
    esLogMessage("eglGetDisplay failed %d\n", eglGetError());
     return EGL_FALSE;
  }
  
  // Initialize EGL
  if ( !eglInitialize(display, &amp;majorVersion, &amp;minorVersion) )
  {
    esLogMessage("eglInitialize failed %d\n", eglGetError());
     return EGL_FALSE;
  }
  
  static const size_t CONFIG_COUNT = 128;
  EGLConfig configs[CONFIG_COUNT];
  
  // Get configs
  if ( !eglGetConfigs(display, configs, CONFIG_COUNT, &amp;numConfigs) )
  {
    esLogMessage("eglGetConfigs failed %d\n", eglGetError());
     return EGL_FALSE;
  }
  else if( numConfigs == 0 )
  {
     esLogMessage("eglGetConfigs found no configs for the display\n");
     return EGL_FALSE;
  }
  
  EGLint chosenConfigCount = 0;
  // Choose config
  if ( !eglChooseConfig(display, attribList, &amp;config, 1, &amp;chosenConfigCount) )
  {
    esLogMessage("eglChooseConfig failed %d\n", eglGetError());
     return EGL_FALSE;
  }
  else if( chosenConfigCount == 0 )
  {
     esLogMessage("eglChooseConfig found no matching configs (%d available)\n", numConfigs);
     return EGL_FALSE;
  }
  
  EGLint format;
  /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
   * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
   * As soon as we picked a EGLConfig, we can safely reconfigure the
   * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
  if( !eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &amp;format) )
  {
     esLogMessage("eglGetConfigAttrib failed %d\n", eglGetError());
     return EGL_FALSE;
  }
  
  #ifdef ANDROID
  
  if( ANativeWindow_setBuffersGeometry(hWnd, 0, 0, format) )
  {
     esLogMessage("ANativeWindow_setBuffersGeometry failed\n");
     return EGL_FALSE;
  }
  
  #endif
  
  // Create a surface
  surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)hWnd, NULL);
  if ( surface == EGL_NO_SURFACE )
  {
     esLogMessage("eglCreateWindowSurface failed %d\n", eglGetError());
     return EGL_FALSE;
  }
  
  // Create a GL context
  context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
  if ( context == EGL_NO_CONTEXT )
  {
     esLogMessage("eglCreateContext failed %d\n", eglGetError());
     return EGL_FALSE;
  }   
  
  // Make the context current
  if ( !eglMakeCurrent(display, surface, surface, context) )
  {
    esLogMessage("eglMakeCurrent failed %d\n", eglGetError());
     return EGL_FALSE;
  }
  </code></pre>
  
  <p>Could someone shed a light, what to test or how to find the problem?</p>
  
  <p>EDIT:</p>
  
  <p>I fixed some other bugs and it now works fine in the Android Emulator and <em>HP Touchpad</em> (Cyanogenmod 9 alpha) but still leads to a black screen on my <em>Samsung Galaxy S1</em> with <em>Cyanogenmod 9</em> *sigh*.</p>