progs: Check the number of configs returned by eglChooseConfig.

A successful eglChooseConfig call does not imply there are valid
configs.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
Chia-I Wu 2010-01-02 21:56:13 +08:00
parent 033bd95802
commit 3bcb08f6c4
6 changed files with 14 additions and 10 deletions

View File

@ -139,7 +139,8 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
!num_configs) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}

View File

@ -66,7 +66,8 @@ make_pbuffer(int width, int height)
EGLConfig config;
EGLint num_configs;
if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs)) {
if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs) ||
!num_configs) {
printf("Error: couldn't get an EGL visual config for pbuffer\n");
exit(1);
}
@ -144,7 +145,8 @@ make_window(Display *x_dpy, const char *name,
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs)) {
if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs) ||
!num_configs) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}

View File

@ -485,7 +485,8 @@ create_window(struct winthread *wt, EGLContext shareCtx)
scrnum = DefaultScreen(wt->Dpy);
root = RootWindow(wt->Dpy, scrnum);
if (!eglChooseConfig(wt->Display, attribs, &config, 1, &num_configs)) {
if (!eglChooseConfig(wt->Display, attribs, &config, 1, &num_configs) ||
!num_configs) {
Error("Unable to choose an EGL config");
}

View File

@ -61,13 +61,13 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
!num_configs) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
assert(config);
assert(num_configs > 0);
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n");

View File

@ -86,13 +86,13 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
!num_configs) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
assert(config);
assert(num_configs > 0);
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n");

View File

@ -61,13 +61,13 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
scrnum = DefaultScreen( x_dpy );
root = RootWindow( x_dpy, scrnum );
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
!num_configs) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
assert(config);
assert(num_configs > 0);
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n");