From: Brian Paul Date: Wed, 4 Jun 2008 17:40:25 +0000 (-0600) Subject: egl: fix X visual selection X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf527cc8d41c277e610d4d51d3b1394e1d417805;p=mesa.git egl: fix X visual selection --- diff --git a/progs/egl/xeglgears.c b/progs/egl/xeglgears.c index d5fbc03410c..72ed0052832 100644 --- a/progs/egl/xeglgears.c +++ b/progs/egl/xeglgears.c @@ -357,7 +357,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy, int num_visuals; EGLContext ctx; EGLConfig config; - EGLint num_configs; + EGLint num_configs, vid; scrnum = DefaultScreen( x_dpy ); root = RootWindow( x_dpy, scrnum ); @@ -373,12 +373,14 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy, exit(1); } - /* choose X window visual similar to EGL config */ - visTemplate.screen = DefaultScreen(x_dpy); - visTemplate.depth = 32; /* 24? */ - visInfo = XGetVisualInfo(x_dpy, - (VisualDepthMask | VisualScreenMask), - &visTemplate, &num_visuals); + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); if (!visInfo) { printf("Error: couldn't get X visual\n"); exit(1);