From 91916269e501e041406b092c7242757d0320b802 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 18 Oct 2016 11:08:12 -0400 Subject: [PATCH] egl: Fix the query for the current context's API Binding an API does not change the type of the current context. Even if it did, EGL 1.5 treats EGL_OPENGL_API and EGL_OPENGLES_API as identical for this purpose. If you want to know properties of the current context, query it. Signed-off-by: Adam Jackson --- src/dispatch_common.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 4f58be2..c0c7156 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -572,31 +572,15 @@ epoxy_get_core_proc_address(const char *name, int core_version) static EGLenum epoxy_egl_get_current_gl_context_api(void) { - EGLenum save_api = eglQueryAPI(); - EGLContext ctx; - - if (eglBindAPI(EGL_OPENGL_API)) { - ctx = eglGetCurrentContext(); - if (ctx) { - eglBindAPI(save_api); - return EGL_OPENGL_API; - } - } else { - (void)eglGetError(); - } + EGLint curapi; - if (eglBindAPI(EGL_OPENGL_ES_API)) { - ctx = eglGetCurrentContext(); - eglBindAPI(save_api); - if (ctx) { - eglBindAPI(save_api); - return EGL_OPENGL_ES_API; - } - } else { - (void)eglGetError(); + if (eglQueryContext(eglGetCurrentDisplay(), eglGetCurrentContext(), + EGL_CONTEXT_CLIENT_TYPE, &curapi) == EGL_FALSE) { + (void)eglGetError(); + return EGL_NONE; } - return EGL_NONE; + return (EGLenum) curapi; } #endif /* PLATFORM_HAS_EGL */