GL/Context: Check return value of eglBindApi()

Fixes some Android devices thinking they got a desktop GL context.
This commit is contained in:
Connor McLaughlin 2020-11-26 22:13:09 +10:00
parent f0e7c744b3
commit dc21f2b5cf

View file

@ -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;