opengl tests
diff --git a/opengl/tests/textures/textures.c b/opengl/tests/textures/textures.c
index 214291b..d877e74 100644
--- a/opengl/tests/textures/textures.c
+++ b/opengl/tests/textures/textures.c
@@ -31,7 +31,7 @@
          EGL_NONE
      };
      
-     EGLint numConfigs = -1;
+     EGLint numConfigs = -1, n=0;
      EGLint majorVersion;
      EGLint minorVersion;
      EGLConfig config;
@@ -43,7 +43,36 @@
 
      dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
      eglInitialize(dpy, &majorVersion, &minorVersion);
-     eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
+     
+     // Get all the "potential match" configs...
+     eglGetConfigs(dpy, NULL, 0, &numConfigs);
+     EGLConfig* const configs = malloc(sizeof(EGLConfig)*numConfigs);
+     eglChooseConfig(dpy, s_configAttribs, configs, numConfigs, &n);
+     config = configs[0];
+     if (n > 1) {
+         // if there is more than one candidate, go through the list
+         // and pick one that matches our framebuffer format
+         int fbSzA = 0; // should not hardcode
+         int fbSzR = 5; // should not hardcode
+         int fbSzG = 6; // should not hardcode
+         int fbSzB = 5; // should not hardcode
+         int i;
+         for (i=0 ; i<n ; i++) {
+             EGLint r,g,b,a;
+             eglGetConfigAttrib(dpy, configs[i], EGL_RED_SIZE,   &r);
+             eglGetConfigAttrib(dpy, configs[i], EGL_GREEN_SIZE, &g);
+             eglGetConfigAttrib(dpy, configs[i], EGL_BLUE_SIZE,  &b);
+             eglGetConfigAttrib(dpy, configs[i], EGL_ALPHA_SIZE, &a);
+             if (fbSzA == a && fbSzR == r && fbSzG == g && fbSzB  == b) {
+                 config = configs[i];
+                 break;
+             }
+         }
+     }
+     free(configs);
+     
+     
+     
      surface = eglCreateWindowSurface(dpy, config,
              android_createDisplaySurface(), NULL);
      context = eglCreateContext(dpy, config, NULL, NULL);