title: Why is eglMakeCurrent() failing with EGL_BAD_MATCH?
body: <p>I am developing for Android using opengl/egl. My app requires a second context for loading textures from a second thread.</p>
  
  <p>My code works fine on android 2.3, but when I try the code on a 4.0.3 android device or emulator, eglMakeCurrent() fails with EGL_BAD_MATCH.</p>
  
  <p>The initialization of the second context and it's pixel buffer all works fine too, so I am not sure where to begin looking for this error.</p>
  
  <p>This is the initialization code:</p>
  
  <pre><code>ANativeWindow *window = (ANativeWindow*)displaySurface;
  
  EGLint dummy, format;
  
  display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
  
  eglInitialize(display, 0, 0);
  
  EGLint contextAttribs[] =
  {
      EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE
  };
  
  const EGLint configAttribs[] =
  {
      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
      EGL_BLUE_SIZE, 8,
      EGL_GREEN_SIZE, 8,
      EGL_RED_SIZE, 8,
      EGL_ALPHA_SIZE, 8,
      EGL_BUFFER_SIZE, 32,
      EGL_DEPTH_SIZE, 24,
      EGL_NONE
  };
  
  EGLint numConfigs;
  EGLConfig config;
  
  eglChooseConfig(display, configAttribs, &amp;config, 1, &amp;numConfigs);
  eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &amp;format);
  ANativeWindow_setBuffersGeometry(window, 0, 0, format);
  
  surface = eglCreateWindowSurface(display, config, window, NULL);
  if(surface == NULL)
      Trace("error creating window surface: " + GetEglError());
  
  context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
  if(context == NULL)
      Trace("error creating main context: " + GetEglError());
  
  const EGLint auxConfigAttribs[] =
  {
      EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
      EGL_BLUE_SIZE, 8,
      EGL_GREEN_SIZE, 8,
      EGL_RED_SIZE, 8,
      EGL_ALPHA_SIZE, 8,
      EGL_DEPTH_SIZE, 0,
      EGL_STENCIL_SIZE, 0,
      EGL_NONE
  };
  
  EGLint pbufferAttribs[] =
  {
      EGL_WIDTH, 1,
      EGL_HEIGHT, 1,
      EGL_TEXTURE_TARGET, EGL_NO_TEXTURE,
      EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE,
      EGL_NONE
  };
  
  EGLint auxNumConfigs;
  EGLConfig auxConfig;
  
  eglChooseConfig(display, auxConfigAttribs, &amp;auxConfig, 1, &amp;auxNumConfigs);
  
  auxSurface = eglCreatePbufferSurface(display, auxConfig, pbufferAttribs);
  if(auxSurface == NULL)
      Trace("error creating pbuffer surface: " + GetEglError());
  
  auxContext = eglCreateContext(display, auxConfig, context, contextAttribs);
  if(auxSurface == NULL)
      Trace("error creating auxilliary context: " + GetEglError());
  
  if(!eglMakeCurrent(display, surface, surface, context))
      Trace("could not make main context current: " + GetEglError());
  </code></pre>
  
  <p>On my Android 2.3 device(HTC Desire), the above initialization code works perfectly, and I can make the auxContext current, and load textures just fine.</p>
  
  <p>BUT, on my android 4.0.3 device(Samsung Nexus S) and my Android 4.1 device (Galaxy Note 2) eglMakeCurrent() fails with EGL_BAD_MATCH after a successful initialization.</p>
  
  <p>Does anyone know why I may be getting this error?</p>