From a7c270f8e2b8dcbf9874632e18a0948255de49d3 Mon Sep 17 00:00:00 2001 From: Yaron Cohen-Tal Date: Thu, 9 Jul 2015 13:44:52 +0300 Subject: [PATCH] Fix epoxy_egl_get_current_gl_context_api() on non-conformant ES. According to the OpenGL ES standard, "glGetString(GL_VERSION)" should return a string starting with "OpenGL ES". However, PowerVR's OpenGL ES implementation (and perhaps others) don't comply with the standard here. If our context happend to be bound using EGL, then we can just ask EGL what kind of context it was, avoiding the glGetString() check. --- src/dispatch_common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 483782c..df167d4 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -192,6 +192,8 @@ static struct api api = { static bool library_initialized; +static bool epoxy_current_context_is_glx(void); + #if PLATFORM_HAS_EGL static EGLenum epoxy_egl_get_current_gl_context_api(void); @@ -269,6 +271,24 @@ epoxy_is_desktop_gl(void) const char *es_prefix = "OpenGL ES"; const char *version; +#if PLATFORM_HAS_EGL + /* PowerVR's OpenGL ES implementation (and perhaps other) don't + * comply with the standard, which states that + * "glGetString(GL_VERSION)" should return a string starting with + * "OpenGL ES". Therefore, to distinguish desktop OpenGL from + * OpenGL ES, we must also check the context type through EGL (we + * can do that as PowerVR is only usable through EGL). + */ + if (!epoxy_current_context_is_glx()) { + switch (epoxy_egl_get_current_gl_context_api()) { + case EGL_OPENGL_API: return true; + case EGL_OPENGL_ES_API: return false; + case EGL_NONE: + default: break; + } + } +#endif + if (api.begin_count) return true;