diff options
author | Eric Anholt <eric@anholt.net> | 2013-12-04 15:56:56 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-05 12:56:58 -0800 |
commit | a258cdcffe9ce30eb7c046aa0ed5fe77e19977b7 (patch) | |
tree | 9727ce3a72df19dcf33314c97817d6b6bedc7877 /test | |
parent | f2d5248e3d6e0cac4584d7b1bd69291dee35b23c (diff) |
Pull a helper function from piglit.
I need this for doing testing against core contexts.
Diffstat (limited to 'test')
-rw-r--r-- | test/glx_common.c | 28 | ||||
-rw-r--r-- | test/glx_common.h | 2 |
2 files changed, 29 insertions, 1 deletions
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); |