From dc21f2b5cfa029734b62d370f2c1de02634d154a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 26 Nov 2020 22:13:09 +1000 Subject: [PATCH] GL/Context: Check return value of eglBindApi() Fixes some Android devices thinking they got a desktop GL context. --- src/common/gl/context_egl.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/common/gl/context_egl.cpp b/src/common/gl/context_egl.cpp index 233e4204d..2ee212907 100644 --- a/src/common/gl/context_egl.cpp +++ b/src/common/gl/context_egl.cpp @@ -218,6 +218,9 @@ bool ContextEGL::CreatePBufferSurface() bool ContextEGL::CreateContext(const Version& version, EGLContext share_context) { + Log_DevPrintf( + "Trying version %u.%u (%s)", version.major_version, version.minor_version, + version.profile == Context::Profile::ES ? "ES" : (version.profile == Context::Profile::Core ? "Core" : "None")); int surface_attribs[16] = { EGL_RENDERABLE_TYPE, (version.profile == Profile::ES) ? @@ -288,10 +291,22 @@ bool ContextEGL::CreateContext(const Version& version, EGLContext share_context) attribs[nattribs++] = EGL_NONE; attribs[nattribs++] = 0; - eglBindAPI((version.profile == Profile::ES) ? EGL_OPENGL_ES_API : EGL_OPENGL_API); + if (!eglBindAPI((version.profile == Profile::ES) ? EGL_OPENGL_ES_API : EGL_OPENGL_API)) + { + Log_ErrorPrintf("eglBindAPI(%s) failed", (version.profile == Profile::ES) ? "EGL_OPENGL_ES_API" : "EGL_OPENGL_API"); + return false; + } + m_context = eglCreateContext(m_display, config, share_context, attribs); if (!m_context) + { + Log_ErrorPrintf("eglCreateContext() failed: %d", eglGetError()); return false; + } + + Log_InfoPrintf( + "Got version %u.%u (%s)", version.major_version, version.minor_version, + version.profile == Context::Profile::ES ? "ES" : (version.profile == Context::Profile::Core ? "Core" : "None")); m_config = config; m_version = version;