diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 9f3dac4..ee42ce3 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -781,12 +781,16 @@ epoxy_get_core_proc_address(const char *name, int core_version) static EGLenum epoxy_egl_get_current_gl_context_api(void) { + EGLDisplay *egl_display = eglGetCurrentDisplay(); + EGLContext *egl_context = eglGetCurrentContext(); EGLint curapi; if (!api.egl_handle) return EGL_NONE; - if (eglQueryContext(eglGetCurrentDisplay(), eglGetCurrentContext(), + if (egl_display == EGL_NO_DISPLAY || + eglQueryContext(egl_display, + egl_context, EGL_CONTEXT_CLIENT_TYPE, &curapi) == EGL_FALSE) { (void)eglGetError(); return EGL_NONE; @@ -817,6 +821,11 @@ epoxy_get_bootstrap_proc_address(const char *name) return epoxy_gl_dlsym(name); #endif +#ifdef _WIN32 + if (api.gl_handle && wglGetCurrentContext()) + return epoxy_gl_dlsym(name); +#endif + /* If epoxy hasn't loaded any API-specific library yet, try to * figure out what API the context is using and use that library, * since future calls will also use that API (this prevents a @@ -830,8 +839,13 @@ epoxy_get_bootstrap_proc_address(const char *name) case EGL_OPENGL_API: return epoxy_gl_dlsym(name); case EGL_OPENGL_ES_API: - if (eglQueryContext(eglGetCurrentDisplay(), - eglGetCurrentContext(), + { + EGLDisplay *egl_display = eglGetCurrentDisplay(); + EGLContext *egl_context = eglGetCurrentContext(); + + if (egl_display != EGL_NO_DISPLAY && + eglQueryContext(egl_display, + egl_context, EGL_CONTEXT_CLIENT_VERSION, &version)) { if (version >= 2) @@ -840,6 +854,7 @@ epoxy_get_bootstrap_proc_address(const char *name) return epoxy_gles1_dlsym(name); } } + } } #endif /* PLATFORM_HAS_EGL */