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.
macos/v1.5.9
Emmanuele Bassi 8 years ago
parent 30b8a4cd2d
commit d94b9c28b5
  1. 1
      include/epoxy/glx.h
  2. 24
      src/dispatch_glx.c

@ -50,6 +50,7 @@ EPOXY_BEGIN_DECLS
EPOXY_PUBLIC bool epoxy_has_glx_extension(Display *dpy, int screen, const char *extension);
EPOXY_PUBLIC int epoxy_glx_version(Display *dpy, int screen);
EPOXY_PUBLIC bool epoxy_has_glx(Display *dpy);
EPOXY_END_DECLS

@ -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 */
}

Loading…
Cancel
Save