summaryrefslogtreecommitdiff
path: root/src/dispatch_glx.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2017-02-03 16:16:13 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2017-02-03 16:16:13 +0000
commitd94b9c28b53b1bf99f4a497486af681d8bc95d95 (patch)
tree12548a90872fd7ba872fe2f688427555da2d3ff7 /src/dispatch_glx.c
parent30b8a4cd2d115eab93ca39709c956f48aa8dadbe (diff)
downloadlibepoxy-d94b9c28b53b1bf99f4a497486af681d8bc95d95.tar.gz
Add epoxy_has_glx()
Libraries and applications that depend on Epoxy currently have no way to safely degrade functionality if they are used on a platform without GLX support; the only way to achieve that is to perform a symbol check themselves, by essentially copying what Epoxy already does. By exposing `epoxy_has_glx()`, those libraries and applications now have the chance of querying Epoxy itself and gracefully handle failure.
Diffstat (limited to 'src/dispatch_glx.c')
-rw-r--r--src/dispatch_glx.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/dispatch_glx.c b/src/dispatch_glx.c
index a74725e..c2b632c 100644
--- a/src/dispatch_glx.c
+++ b/src/dispatch_glx.c
@@ -133,7 +133,7 @@ epoxy_conservative_has_glx_extension(const char *ext)
*/
bool
epoxy_has_glx_extension(Display *dpy, int screen, const char *ext)
- {
+{
/* No, you can't just use glXGetClientString or
* glXGetServerString() here. Those each tell you about one half
* of what's needed for an extension to be supported, and
@@ -142,3 +142,27 @@ epoxy_has_glx_extension(Display *dpy, int screen, const char *ext)
*/
return epoxy_extension_in_string(glXQueryExtensionsString(dpy, screen), ext);
}
+
+/**
+ * @brief Checks whether GLX is available.
+ *
+ * @param dpy The X11 display
+ *
+ * @return `true` if GLX is available
+ */
+bool
+epoxy_has_glx(Display *dpy)
+{
+#if !PLATFORM_HAS_GLX
+ return false;
+#else
+ Bool (* pf_glXQueryExtension) (Display *, int *, int *);
+ int error_base, event_base;
+
+ pf_glXQueryExtension = epoxy_conservative_glx_dlsym("glXQueryExtension", false);
+ if (pf_glXQueryExtension && pf_glXQueryExtension(dpy, &error_base, &event_base))
+ return true;
+
+ return false;
+#endif /* !PLATFORM_HAS_GLX */
+}