fix test-opengl-swapinterval

EGLConfig selection should now work on any device

Change-Id: I4d4580e891d1faf817fa853838406fb49d12e50a
This commit is contained in:
Mathias Agopian 2011-08-15 14:56:38 -07:00
parent f9606df42b
commit 7dddeac971

View File

@ -48,31 +48,35 @@ int main(int argc, char** argv)
EGLNativeWindowType window = android_createDisplaySurface(); EGLNativeWindowType window = android_createDisplaySurface();
dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(dpy, 0 ,0) ;//&majorVersion, &minorVersion); eglInitialize(dpy, &majorVersion, &minorVersion);
eglGetConfigs(dpy, NULL, 0, &numConfigs); eglGetConfigs(dpy, NULL, 0, &numConfigs);
printf("# configs = %d\n", numConfigs); printf("# configs = %d\n", numConfigs);
status_t err = EGLUtils::selectConfigForNativeWindow( status_t err = EGLUtils::selectConfigForNativeWindow(
dpy, configAttribs, window, &config); dpy, configAttribs, window, &config);
if (err) { if (err) {
fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n"); fprintf(stderr, "error: %s", EGLUtils::strerror(eglGetError()));
eglTerminate(dpy);
return 0; return 0;
} }
EGLint r,g,b,a; EGLint r,g,b,a, vid;
eglGetConfigAttrib(dpy, config, EGL_RED_SIZE, &r); eglGetConfigAttrib(dpy, config, EGL_RED_SIZE, &r);
eglGetConfigAttrib(dpy, config, EGL_GREEN_SIZE, &g); eglGetConfigAttrib(dpy, config, EGL_GREEN_SIZE, &g);
eglGetConfigAttrib(dpy, config, EGL_BLUE_SIZE, &b); eglGetConfigAttrib(dpy, config, EGL_BLUE_SIZE, &b);
eglGetConfigAttrib(dpy, config, EGL_ALPHA_SIZE, &a); eglGetConfigAttrib(dpy, config, EGL_ALPHA_SIZE, &a);
eglGetConfigAttrib(dpy, config, EGL_NATIVE_VISUAL_ID, &vid);
surface = eglCreateWindowSurface(dpy, config, window, NULL); surface = eglCreateWindowSurface(dpy, config, window, NULL);
if (surface == EGL_NO_SURFACE) { if (surface == EGL_NO_SURFACE) {
EGLint err = eglGetError(); EGLint err = eglGetError();
fprintf(stderr, "%s, config=%p, format = %d-%d-%d-%d\n", fprintf(stderr, "error: %s, config=%p, format = %d-%d-%d-%d, visual-id = %d\n",
EGLUtils::strerror(err), config, r,g,b,a); EGLUtils::strerror(err), config, r,g,b,a, vid);
eglTerminate(dpy);
return 0; return 0;
} else { } else {
printf("config=%p, format = %d-%d-%d-%d\n", config, r,g,b,a); printf("config=%p, format = %d-%d-%d-%d, visual-id = %d\n",
config, r,g,b,a, vid);
} }
context = eglCreateContext(dpy, config, NULL, NULL); context = eglCreateContext(dpy, config, NULL, NULL);