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