forked from AuroraMiddleware/gtk
glcontext: Handle failure of eglBindAPI()
We don't want to be sure if we have GL or GLES.
This commit is contained in:
parent
2ff1ea555f
commit
3ca84c4357
@ -384,10 +384,8 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
if (forward_bit)
|
if (forward_bit)
|
||||||
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
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 */
|
/* We want a core profile, unless in legacy mode */
|
||||||
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
||||||
context_attribs[i++] = legacy_bit
|
context_attribs[i++] = legacy_bit
|
||||||
@ -400,16 +398,20 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
|
context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
|
||||||
context_attribs[i++] = legacy_bit ? 0 : minor;
|
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;
|
context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
|
||||||
if (major == 3)
|
if (major == 3)
|
||||||
context_attribs[i++] = 3;
|
context_attribs[i++] = 3;
|
||||||
else
|
else
|
||||||
context_attribs[i++] = 2;
|
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 */
|
/* Specify the flags */
|
||||||
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
|
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
|
||||||
@ -433,7 +435,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
context_attribs);
|
context_attribs);
|
||||||
|
|
||||||
/* If context creation failed without the ES bit, let's try again with it */
|
/* 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;
|
i = 0;
|
||||||
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
|
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
|
||||||
@ -445,8 +447,6 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
context_attribs[i++] = EGL_NONE;
|
context_attribs[i++] = EGL_NONE;
|
||||||
g_assert (i < N_EGL_ATTRS);
|
g_assert (i < N_EGL_ATTRS);
|
||||||
|
|
||||||
eglBindAPI (EGL_OPENGL_ES_API);
|
|
||||||
|
|
||||||
legacy_bit = FALSE;
|
legacy_bit = FALSE;
|
||||||
use_es = TRUE;
|
use_es = TRUE;
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If context creation failed without the legacy bit, let's try again with it */
|
/* 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;
|
i = 0;
|
||||||
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
||||||
@ -474,8 +474,6 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
context_attribs[i++] = EGL_NONE;
|
context_attribs[i++] = EGL_NONE;
|
||||||
g_assert (i < N_EGL_ATTRS);
|
g_assert (i < N_EGL_ATTRS);
|
||||||
|
|
||||||
eglBindAPI (EGL_OPENGL_API);
|
|
||||||
|
|
||||||
legacy_bit = TRUE;
|
legacy_bit = TRUE;
|
||||||
use_es = FALSE;
|
use_es = FALSE;
|
||||||
|
|
||||||
@ -510,7 +508,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user