From 075172f485fe7d4006f84237eef49a586b92c380 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 3 Feb 2017 16:19:30 +0000 Subject: [PATCH] Add epoxy_has_egl() Similar to `epoxy_has_glx()`, but for the EGL windowing system API. --- include/epoxy/egl.h | 1 + src/dispatch_egl.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/epoxy/egl.h b/include/epoxy/egl.h index 2550acc..d5083da 100644 --- a/include/epoxy/egl.h +++ b/include/epoxy/egl.h @@ -47,6 +47,7 @@ EPOXY_BEGIN_DECLS EPOXY_PUBLIC bool epoxy_has_egl_extension(EGLDisplay dpy, const char *extension); EPOXY_PUBLIC int epoxy_egl_version(EGLDisplay dpy); +EPOXY_PUBLIC bool epoxy_has_egl(void); EPOXY_END_DECLS diff --git a/src/dispatch_egl.c b/src/dispatch_egl.c index 7f970d9..a85a016 100644 --- a/src/dispatch_egl.c +++ b/src/dispatch_egl.c @@ -92,3 +92,24 @@ epoxy_has_egl_extension(EGLDisplay dpy, const char *ext) { return epoxy_extension_in_string(eglQueryString(dpy, EGL_EXTENSIONS), ext) || epoxy_extension_in_string(eglQueryString(NULL, EGL_EXTENSIONS), ext); } + +/** + * @brief Checks whether EGL is available. + * + * @return `true` if EGL is available + */ +bool +epoxy_has_egl(void) +{ +#if !PLATFORM_HAS_EGL + return false; +#else + EGLDisplay* (* pf_eglGetCurrentDisplay) (void); + + pf_eglGetCurrentDisplay = epoxy_conservative_egl_dlsym("eglGetCurrentDisplay", false); + if (pf_eglGetCurrentDisplay) + return true; + + return false; +#endif /* PLATFORM_HAS_EGL */ +}