From bf527cc8d41c277e610d4d51d3b1394e1d417805 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 Jun 2008 11:40:25 -0600 Subject: egl: fix X visual selection --- progs/egl/xeglgears.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'progs') diff --git a/progs/egl/xeglgears.c b/progs/egl/xeglgears.c index d5fbc0341..72ed00528 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); -- cgit v1.2.3