diff options
author | Mathias Agopian <mathias@google.com> | 2009-08-04 13:43:35 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-08-05 12:22:29 -0700 |
commit | 429c521b15112fdcc70dca602b432fae45ca3a22 (patch) | |
tree | 9531ef4de47d0ce5845d419774408c989a5dd620 /opengl/tests/angeles | |
parent | 859c37548f4ed1d466b7edc6a01e579b6b55039f (diff) | |
download | frameworks_base-429c521b15112fdcc70dca602b432fae45ca3a22.zip frameworks_base-429c521b15112fdcc70dca602b432fae45ca3a22.tar.gz frameworks_base-429c521b15112fdcc70dca602b432fae45ca3a22.tar.bz2 |
opengl tests
Diffstat (limited to 'opengl/tests/angeles')
-rw-r--r-- | opengl/tests/angeles/app-linux.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/opengl/tests/angeles/app-linux.c b/opengl/tests/angeles/app-linux.c index 7d0d320..6be4876 100644 --- a/opengl/tests/angeles/app-linux.c +++ b/opengl/tests/angeles/app-linux.c @@ -132,6 +132,7 @@ static int initGraphics() }; EGLint numConfigs = -1; + EGLint n = 0; EGLint majorVersion; EGLint minorVersion; EGLConfig config; @@ -148,15 +149,43 @@ static int initGraphics() egl_error("eglInitialize"); eglGetConfigs(dpy, NULL, 0, &numConfigs); - egl_error("eglGetConfigs"); - fprintf(stderr,"num configs %d\n", numConfigs); + + // Get all the "potential match" configs... + 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); + - eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs); - egl_error("eglChooseConfig"); + //eglGetConfigs(dpy, NULL, 0, &numConfigs); + //egl_error("eglGetConfigs"); + //fprintf(stderr,"num configs %d\n", numConfigs); + //eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs); + //egl_error("eglChooseConfig"); surface = eglCreateWindowSurface(dpy, config, android_createDisplaySurface(), NULL); - egl_error("eglMapWindowSurface"); + egl_error("eglCreateWindowSurface"); fprintf(stderr,"surface = %p\n", surface); |