From a258cdcffe9ce30eb7c046aa0ed5fe77e19977b7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Dec 2013 15:56:56 -0800 Subject: [PATCH] Pull a helper function from piglit. I need this for doing testing against core contexts. --- test/glx_common.c | 28 +++++++++++++++++++++++++++- test/glx_common.h | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/test/glx_common.c b/test/glx_common.c index 1c1b3f5..1c00a6a 100644 --- a/test/glx_common.c +++ b/test/glx_common.c @@ -1,5 +1,5 @@ /* - * Copyright © 2013 Intel Corporation + * Copyright © 2009, 2013 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -102,3 +102,29 @@ make_glx_context_current_or_skip(Display *dpy) glXMakeCurrent(dpy, win, ctx); } + +GLXFBConfig +get_fbconfig_for_visinfo(Display *dpy, XVisualInfo *visinfo) +{ + int i, nconfigs; + GLXFBConfig ret = None, *configs; + + configs = glXGetFBConfigs(dpy, visinfo->screen, &nconfigs); + if (!configs) + return None; + + for (i = 0; i < nconfigs; i++) { + int v; + + if (glXGetFBConfigAttrib(dpy, configs[i], GLX_VISUAL_ID, &v)) + continue; + + if (v == visinfo->visualid) { + ret = configs[i]; + break; + } + } + + XFree(configs); + return ret; +} diff --git a/test/glx_common.h b/test/glx_common.h index 35882f5..544d3d9 100644 --- a/test/glx_common.h +++ b/test/glx_common.h @@ -29,3 +29,5 @@ get_display_or_skip(void); GLXContext make_glx_context_current_or_skip(Display *dpy); +GLXFBConfig +get_fbconfig_for_visual(XVisualInfo *visinfo);