if (forward_bit)
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
- if (!use_es)
+ if (!use_es && eglBindAPI (EGL_OPENGL_API))
{
- eglBindAPI (EGL_OPENGL_API);
-
/* We want a core profile, unless in legacy mode */
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
context_attribs[i++] = legacy_bit
context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
context_attribs[i++] = legacy_bit ? 0 : minor;
}
- else
+ else if (eglBindAPI (EGL_OPENGL_ES_API))
{
- eglBindAPI (EGL_OPENGL_ES_API);
-
context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
if (major == 3)
context_attribs[i++] = 3;
else
context_attribs[i++] = 2;
}
+ else
+ {
+ g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
+ _("The EGL implementation supports neither OpenGL nor GLES"));
+ return FALSE;
+ }
/* Specify the flags */
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
context_attribs);
/* If context creation failed without the ES bit, let's try again with it */
- if (ctx == NULL)
+ if (ctx == NULL && eglBindAPI (EGL_OPENGL_ES_API))
{
i = 0;
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
context_attribs[i++] = EGL_NONE;
g_assert (i < N_EGL_ATTRS);
- eglBindAPI (EGL_OPENGL_ES_API);
-
legacy_bit = FALSE;
use_es = TRUE;
}
/* If context creation failed without the legacy bit, let's try again with it */
- if (ctx == NULL)
+ if (ctx == NULL && eglBindAPI (EGL_OPENGL_API))
{
i = 0;
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
context_attribs[i++] = EGL_NONE;
g_assert (i < N_EGL_ATTRS);
- eglBindAPI (EGL_OPENGL_API);
-
legacy_bit = TRUE;
use_es = FALSE;
#endif
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
- "The current backend does not support OpenGL");
+ _("The current backend does not support OpenGL"));
return FALSE;
}