gl: Check allowed APIs in realize()
Add gdk_gl_context_is_api_allowed() for backends and make them use it. Finally, have them return the final API as the return value (or 0 on error). And then use that api instead of a use_es boolean flag. Fixes #4221
This commit is contained in:
@@ -121,7 +121,7 @@ static const GdkDebugKey gdk_debug_keys[] = {
|
|||||||
{ "gl-software", GDK_DEBUG_GL_SOFTWARE, "Force OpenGL software rendering" },
|
{ "gl-software", GDK_DEBUG_GL_SOFTWARE, "Force OpenGL software rendering" },
|
||||||
{ "gl-texture-rect", GDK_DEBUG_GL_TEXTURE_RECT, "Use OpenGL texture rectangle extension" },
|
{ "gl-texture-rect", GDK_DEBUG_GL_TEXTURE_RECT, "Use OpenGL texture rectangle extension" },
|
||||||
{ "gl-legacy", GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context" },
|
{ "gl-legacy", GDK_DEBUG_GL_LEGACY, "Use a legacy OpenGL context" },
|
||||||
{ "gl-gles", GDK_DEBUG_GL_GLES, "Use a GLES OpenGL context" },
|
{ "gl-gles", GDK_DEBUG_GL_GLES, "Only allow OpenGL GLES API" },
|
||||||
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
|
{ "gl-debug", GDK_DEBUG_GL_DEBUG, "Insert debugging information in OpenGL" },
|
||||||
{ "gl-egl", GDK_DEBUG_GL_EGL, "Use EGL on X11 or Windows" },
|
{ "gl-egl", GDK_DEBUG_GL_EGL, "Use EGL on X11 or Windows" },
|
||||||
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
|
{ "gl-glx", GDK_DEBUG_GL_GLX, "Use GLX on X11" },
|
||||||
|
@@ -101,7 +101,6 @@ typedef struct {
|
|||||||
int minor;
|
int minor;
|
||||||
int gl_version;
|
int gl_version;
|
||||||
|
|
||||||
guint realized : 1;
|
|
||||||
guint has_khr_debug : 1;
|
guint has_khr_debug : 1;
|
||||||
guint use_khr_debug : 1;
|
guint use_khr_debug : 1;
|
||||||
guint has_unpack_subimage : 1;
|
guint has_unpack_subimage : 1;
|
||||||
@@ -112,7 +111,7 @@ typedef struct {
|
|||||||
guint is_legacy : 1;
|
guint is_legacy : 1;
|
||||||
|
|
||||||
GdkGLAPI allowed_apis;
|
GdkGLAPI allowed_apis;
|
||||||
int use_es;
|
GdkGLAPI api;
|
||||||
|
|
||||||
int max_debug_label_length;
|
int max_debug_label_length;
|
||||||
|
|
||||||
@@ -264,7 +263,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
|
|||||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||||
|
|
||||||
if (!gdk_memory_format_gl_format (data_format,
|
if (!gdk_memory_format_gl_format (data_format,
|
||||||
priv->use_es,
|
gdk_gl_context_get_use_es (context),
|
||||||
&gl_internalformat,
|
&gl_internalformat,
|
||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type))
|
&gl_type))
|
||||||
@@ -278,7 +277,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
|
|||||||
data = copy;
|
data = copy;
|
||||||
data_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
data_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED;
|
||||||
if (!gdk_memory_format_gl_format (data_format,
|
if (!gdk_memory_format_gl_format (data_format,
|
||||||
priv->use_es,
|
gdk_gl_context_get_use_es (context),
|
||||||
&gl_internalformat,
|
&gl_internalformat,
|
||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type))
|
&gl_type))
|
||||||
@@ -303,8 +302,8 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
|
|||||||
glTexImage2D (texture_target, 0, gl_internalformat, width, height, 0, gl_format, gl_type, data);
|
glTexImage2D (texture_target, 0, gl_internalformat, width, height, 0, gl_format, gl_type, data);
|
||||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||||
}
|
}
|
||||||
else if ((!priv->use_es ||
|
else if ((!gdk_gl_context_get_use_es (context) ||
|
||||||
(priv->use_es && (priv->gl_version >= 30 || priv->has_unpack_subimage))))
|
(priv->gl_version >= 30 || priv->has_unpack_subimage)))
|
||||||
{
|
{
|
||||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / bpp);
|
glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / bpp);
|
||||||
|
|
||||||
@@ -325,7 +324,7 @@ gdk_gl_context_upload_texture (GdkGLContext *context,
|
|||||||
|
|
||||||
#define N_EGL_ATTRS 16
|
#define N_EGL_ATTRS 16
|
||||||
|
|
||||||
static gboolean
|
static GdkGLAPI
|
||||||
gdk_gl_context_real_realize (GdkGLContext *context,
|
gdk_gl_context_real_realize (GdkGLContext *context,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@@ -342,7 +341,8 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
EGLContext ctx;
|
EGLContext ctx;
|
||||||
EGLint context_attribs[N_EGL_ATTRS];
|
EGLint context_attribs[N_EGL_ATTRS];
|
||||||
int major, minor, flags;
|
int major, minor, flags;
|
||||||
gboolean debug_bit, forward_bit, legacy_bit, use_es;
|
gboolean debug_bit, forward_bit, legacy_bit;
|
||||||
|
GdkGLAPI api;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||||
|
|
||||||
@@ -351,8 +351,6 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
forward_bit = gdk_gl_context_get_forward_compatible (context);
|
forward_bit = gdk_gl_context_get_forward_compatible (context);
|
||||||
legacy_bit = GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY) ||
|
legacy_bit = GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY) ||
|
||||||
(share != NULL && gdk_gl_context_is_legacy (share));
|
(share != NULL && gdk_gl_context_is_legacy (share));
|
||||||
use_es = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) ||
|
|
||||||
(share != NULL && gdk_gl_context_get_use_es (share));
|
|
||||||
|
|
||||||
if (display->have_egl_no_config_context)
|
if (display->have_egl_no_config_context)
|
||||||
egl_config = NULL;
|
egl_config = NULL;
|
||||||
@@ -366,7 +364,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 && eglBindAPI (EGL_OPENGL_API))
|
if (gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL) &&
|
||||||
|
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;
|
||||||
@@ -379,20 +378,23 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
context_attribs[i++] = legacy_bit ? 3 : major;
|
context_attribs[i++] = legacy_bit ? 3 : major;
|
||||||
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;
|
||||||
|
api = GDK_GL_API_GL;
|
||||||
}
|
}
|
||||||
else if (eglBindAPI (EGL_OPENGL_ES_API))
|
else if (gdk_gl_context_is_api_allowed (context, GDK_GL_API_GLES, NULL) &&
|
||||||
|
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;
|
||||||
|
api = GDK_GL_API_GLES;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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 EGL implementation supports neither OpenGL nor GLES"));
|
_("The EGL implementation does not support any allowed APIs"));
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Specify the flags */
|
/* Specify the flags */
|
||||||
@@ -408,7 +410,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
debug_bit ? "yes" : "no",
|
debug_bit ? "yes" : "no",
|
||||||
forward_bit ? "yes" : "no",
|
forward_bit ? "yes" : "no",
|
||||||
legacy_bit ? "yes" : "no",
|
legacy_bit ? "yes" : "no",
|
||||||
use_es ? "yes" : "no"));
|
api == GDK_GL_API_GLES ? "yes" : "no"));
|
||||||
|
|
||||||
ctx = eglCreateContext (egl_display,
|
ctx = eglCreateContext (egl_display,
|
||||||
egl_config,
|
egl_config,
|
||||||
@@ -417,7 +419,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 && eglBindAPI (EGL_OPENGL_ES_API))
|
if (ctx == NULL && gdk_gl_context_is_api_allowed (context, GDK_GL_API_GLES, NULL) && eglBindAPI (EGL_OPENGL_ES_API))
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
|
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION;
|
||||||
@@ -430,7 +432,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
g_assert (i < N_EGL_ATTRS);
|
g_assert (i < N_EGL_ATTRS);
|
||||||
|
|
||||||
legacy_bit = FALSE;
|
legacy_bit = FALSE;
|
||||||
use_es = TRUE;
|
api = GDK_GL_API_GLES;
|
||||||
|
|
||||||
GDK_DISPLAY_NOTE (display, OPENGL,
|
GDK_DISPLAY_NOTE (display, OPENGL,
|
||||||
g_message ("eglCreateContext failed, switching to OpenGL ES"));
|
g_message ("eglCreateContext failed, switching to OpenGL ES"));
|
||||||
@@ -442,7 +444,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 && eglBindAPI (EGL_OPENGL_API))
|
if (ctx == NULL && gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, 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;
|
||||||
@@ -457,7 +459,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
g_assert (i < N_EGL_ATTRS);
|
g_assert (i < N_EGL_ATTRS);
|
||||||
|
|
||||||
legacy_bit = TRUE;
|
legacy_bit = TRUE;
|
||||||
use_es = FALSE;
|
api = GDK_GL_API_GL;
|
||||||
|
|
||||||
GDK_DISPLAY_NOTE (display, OPENGL,
|
GDK_DISPLAY_NOTE (display, OPENGL,
|
||||||
g_message ("eglCreateContext failed, switching to legacy"));
|
g_message ("eglCreateContext failed, switching to legacy"));
|
||||||
@@ -473,7 +475,7 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
g_set_error_literal (error, GDK_GL_ERROR,
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
_("Unable to create a GL context"));
|
_("Unable to create a GL context"));
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Created EGL context[%p]", ctx));
|
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Created EGL context[%p]", ctx));
|
||||||
@@ -481,17 +483,16 @@ gdk_gl_context_real_realize (GdkGLContext *context,
|
|||||||
priv->egl_context = ctx;
|
priv->egl_context = ctx;
|
||||||
|
|
||||||
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
||||||
gdk_gl_context_set_use_es (context, use_es);
|
|
||||||
|
|
||||||
gdk_profiler_end_mark (start_time, "realize GdkWaylandGLContext", NULL);
|
gdk_profiler_end_mark (start_time, "realize GdkWaylandGLContext", NULL);
|
||||||
|
|
||||||
return TRUE;
|
return api;
|
||||||
}
|
}
|
||||||
#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 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef N_EGL_ATTRS
|
#undef N_EGL_ATTRS
|
||||||
@@ -879,6 +880,14 @@ gdk_gl_context_has_unpack_subimage (GdkGLContext *context)
|
|||||||
return priv->has_unpack_subimage;
|
return priv->has_unpack_subimage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gdk_gl_context_is_realized (GdkGLContext *context)
|
||||||
|
{
|
||||||
|
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||||
|
|
||||||
|
return priv->api != 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_gl_context_set_debug_enabled:
|
* gdk_gl_context_set_debug_enabled:
|
||||||
* @context: a `GdkGLContext`
|
* @context: a `GdkGLContext`
|
||||||
@@ -899,7 +908,7 @@ gdk_gl_context_set_debug_enabled (GdkGLContext *context,
|
|||||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||||
g_return_if_fail (!priv->realized);
|
g_return_if_fail (gdk_gl_context_is_realized (context));
|
||||||
|
|
||||||
enabled = !!enabled;
|
enabled = !!enabled;
|
||||||
|
|
||||||
@@ -948,7 +957,7 @@ gdk_gl_context_set_forward_compatible (GdkGLContext *context,
|
|||||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||||
g_return_if_fail (!priv->realized);
|
g_return_if_fail (gdk_gl_context_is_realized (context));
|
||||||
|
|
||||||
compatible = !!compatible;
|
compatible = !!compatible;
|
||||||
|
|
||||||
@@ -1001,7 +1010,7 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||||
g_return_if_fail (!priv->realized);
|
g_return_if_fail (gdk_gl_context_is_realized (context));
|
||||||
|
|
||||||
/* this will take care of the default */
|
/* this will take care of the default */
|
||||||
if (major == 0 && minor == 0)
|
if (major == 0 && minor == 0)
|
||||||
@@ -1020,7 +1029,7 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
|
|||||||
/* Enforce a minimum context version number of 3.2 for desktop GL,
|
/* Enforce a minimum context version number of 3.2 for desktop GL,
|
||||||
* and 2.0 for GLES
|
* and 2.0 for GLES
|
||||||
*/
|
*/
|
||||||
if (priv->use_es > 0 || force_gles)
|
if (gdk_gl_context_get_use_es (context) || force_gles)
|
||||||
min_ver = 200;
|
min_ver = 200;
|
||||||
else
|
else
|
||||||
min_ver = 302;
|
min_ver = 302;
|
||||||
@@ -1068,7 +1077,7 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
|
|||||||
* enforce a context version number of 3.2 for desktop GL,
|
* enforce a context version number of 3.2 for desktop GL,
|
||||||
* and 2.0 for GLES
|
* and 2.0 for GLES
|
||||||
*/
|
*/
|
||||||
if (priv->use_es > 0 || force_gles)
|
if (gdk_gl_context_get_use_es (context) || force_gles)
|
||||||
{
|
{
|
||||||
default_major = 2;
|
default_major = 2;
|
||||||
default_minor = 0;
|
default_minor = 0;
|
||||||
@@ -1124,7 +1133,7 @@ gdk_gl_context_is_legacy (GdkGLContext *context)
|
|||||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
|
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
|
||||||
g_return_val_if_fail (priv->realized, FALSE);
|
g_return_val_if_fail (gdk_gl_context_is_realized (context), FALSE);
|
||||||
|
|
||||||
return priv->is_legacy;
|
return priv->is_legacy;
|
||||||
}
|
}
|
||||||
@@ -1164,13 +1173,11 @@ gboolean
|
|||||||
gdk_gl_context_is_shared (GdkGLContext *self,
|
gdk_gl_context_is_shared (GdkGLContext *self,
|
||||||
GdkGLContext *other)
|
GdkGLContext *other)
|
||||||
{
|
{
|
||||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
|
|
||||||
GdkGLContextPrivate *priv_other = gdk_gl_context_get_instance_private (other);
|
|
||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), FALSE);
|
g_return_val_if_fail (GDK_IS_GL_CONTEXT (self), FALSE);
|
||||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (other), FALSE);
|
g_return_val_if_fail (GDK_IS_GL_CONTEXT (other), FALSE);
|
||||||
|
|
||||||
if (!priv->realized || !priv_other->realized)
|
if (!gdk_gl_context_is_realized (self) ||
|
||||||
|
!gdk_gl_context_is_realized (other))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return GDK_GL_CONTEXT_GET_CLASS (self)->is_shared (self, other);
|
return GDK_GL_CONTEXT_GET_CLASS (self)->is_shared (self, other);
|
||||||
@@ -1227,6 +1234,33 @@ gdk_gl_context_get_allowed_apis (GdkGLContext *self)
|
|||||||
return priv->allowed_apis;
|
return priv->allowed_apis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gdk_gl_context_is_api_allowed (GdkGLContext *self,
|
||||||
|
GdkGLAPI api,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
|
||||||
|
|
||||||
|
if (GDK_DISPLAY_DEBUG_CHECK (gdk_gl_context_get_display (self), GL_GLES))
|
||||||
|
{
|
||||||
|
if (!(api & GDK_GL_API_GLES))
|
||||||
|
{
|
||||||
|
g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
_("Anything but OpenGL ES disabled via GDK_DEBUG"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->allowed_apis & api)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
|
_("Application does not support %s API"),
|
||||||
|
api == GDK_GL_API_GL ? "OpenGL" : "OpenGL ES");
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_gl_context_set_use_es:
|
* gdk_gl_context_set_use_es:
|
||||||
* @context: a `GdkGLContext`
|
* @context: a `GdkGLContext`
|
||||||
@@ -1246,17 +1280,13 @@ gdk_gl_context_get_allowed_apis (GdkGLContext *self)
|
|||||||
* You should check the return value of [method@Gdk.GLContext.get_use_es]
|
* You should check the return value of [method@Gdk.GLContext.get_use_es]
|
||||||
* after calling [method@Gdk.GLContext.realize] to decide whether to use
|
* after calling [method@Gdk.GLContext.realize] to decide whether to use
|
||||||
* the OpenGL or OpenGL ES API, extensions, or shaders.
|
* the OpenGL or OpenGL ES API, extensions, or shaders.
|
||||||
*
|
|
||||||
* Deprecated: 4.6: Use gdk_gl_context_set_allowed_apis() instead.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gdk_gl_context_set_use_es (GdkGLContext *context,
|
gdk_gl_context_set_use_es (GdkGLContext *context,
|
||||||
int use_es)
|
int use_es)
|
||||||
{
|
{
|
||||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||||
g_return_if_fail (!priv->realized);
|
g_return_if_fail (gdk_gl_context_is_realized (context));
|
||||||
|
|
||||||
switch (use_es)
|
switch (use_es)
|
||||||
{
|
{
|
||||||
@@ -1290,10 +1320,7 @@ gdk_gl_context_get_use_es (GdkGLContext *context)
|
|||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
|
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
|
||||||
|
|
||||||
if (!priv->realized)
|
return priv->api == GDK_GL_API_GLES;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return priv->use_es > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void APIENTRY
|
static void APIENTRY
|
||||||
@@ -1406,12 +1433,12 @@ gdk_gl_context_realize (GdkGLContext *context,
|
|||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
|
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
|
||||||
|
|
||||||
if (priv->realized)
|
if (priv->api)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
priv->realized = GDK_GL_CONTEXT_GET_CLASS (context)->realize (context, error);
|
priv->api = GDK_GL_CONTEXT_GET_CLASS (context)->realize (context, error);
|
||||||
|
|
||||||
return priv->realized;
|
return priv->api;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1423,7 +1450,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
|||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!priv->realized)
|
if (!gdk_gl_context_is_realized (context))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (priv->extensions_checked)
|
if (priv->extensions_checked)
|
||||||
@@ -1431,9 +1458,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
|||||||
|
|
||||||
priv->gl_version = epoxy_gl_version ();
|
priv->gl_version = epoxy_gl_version ();
|
||||||
|
|
||||||
if (priv->use_es < 0)
|
|
||||||
priv->use_es = !epoxy_is_desktop_gl ();
|
|
||||||
|
|
||||||
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
|
priv->has_debug_output = epoxy_has_gl_extension ("GL_ARB_debug_output") ||
|
||||||
epoxy_has_gl_extension ("GL_KHR_debug");
|
epoxy_has_gl_extension ("GL_KHR_debug");
|
||||||
|
|
||||||
@@ -1454,7 +1478,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
|||||||
glDebugMessageCallback (gl_debug_message_callback, NULL);
|
glDebugMessageCallback (gl_debug_message_callback, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->use_es)
|
if (gdk_gl_context_get_use_es (context))
|
||||||
{
|
{
|
||||||
priv->has_unpack_subimage = epoxy_has_gl_extension ("GL_EXT_unpack_subimage");
|
priv->has_unpack_subimage = epoxy_has_gl_extension ("GL_EXT_unpack_subimage");
|
||||||
priv->has_khr_debug = epoxy_has_gl_extension ("GL_KHR_debug");
|
priv->has_khr_debug = epoxy_has_gl_extension ("GL_KHR_debug");
|
||||||
@@ -1481,7 +1505,7 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
|||||||
"* Extensions checked:\n"
|
"* Extensions checked:\n"
|
||||||
" - GL_KHR_debug: %s\n"
|
" - GL_KHR_debug: %s\n"
|
||||||
" - GL_EXT_unpack_subimage: %s",
|
" - GL_EXT_unpack_subimage: %s",
|
||||||
priv->use_es ? "OpenGL ES" : "OpenGL",
|
gdk_gl_context_get_use_es (context) ? "OpenGL ES" : "OpenGL",
|
||||||
priv->gl_version / 10, priv->gl_version % 10,
|
priv->gl_version / 10, priv->gl_version % 10,
|
||||||
priv->is_legacy ? "legacy" : "core",
|
priv->is_legacy ? "legacy" : "core",
|
||||||
glGetString (GL_SHADING_LANGUAGE_VERSION),
|
glGetString (GL_SHADING_LANGUAGE_VERSION),
|
||||||
@@ -1500,7 +1524,6 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
|
|||||||
void
|
void
|
||||||
gdk_gl_context_make_current (GdkGLContext *context)
|
gdk_gl_context_make_current (GdkGLContext *context)
|
||||||
{
|
{
|
||||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
|
||||||
MaskedContext *current, *masked_context;
|
MaskedContext *current, *masked_context;
|
||||||
gboolean surfaceless;
|
gboolean surfaceless;
|
||||||
|
|
||||||
@@ -1514,7 +1537,7 @@ gdk_gl_context_make_current (GdkGLContext *context)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* we need to realize the GdkGLContext if it wasn't explicitly realized */
|
/* we need to realize the GdkGLContext if it wasn't explicitly realized */
|
||||||
if (!priv->realized)
|
if (!gdk_gl_context_is_realized (context))
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
@@ -1610,7 +1633,7 @@ gdk_gl_context_get_version (GdkGLContext *context,
|
|||||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||||
|
|
||||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||||
g_return_if_fail (priv->realized);
|
g_return_if_fail (gdk_gl_context_is_realized (context));
|
||||||
|
|
||||||
if (major != NULL)
|
if (major != NULL)
|
||||||
*major = priv->gl_version / 10;
|
*major = priv->gl_version / 10;
|
||||||
|
@@ -62,7 +62,7 @@ struct _GdkGLContextClass
|
|||||||
|
|
||||||
GdkGLBackend backend_type;
|
GdkGLBackend backend_type;
|
||||||
|
|
||||||
gboolean (* realize) (GdkGLContext *context,
|
GdkGLAPI (* realize) (GdkGLContext *context,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean (* make_current) (GdkGLContext *context,
|
gboolean (* make_current) (GdkGLContext *context,
|
||||||
@@ -102,6 +102,9 @@ void gdk_gl_backend_use (GdkGLBackend
|
|||||||
|
|
||||||
GdkGLContext * gdk_gl_context_new_for_surface (GdkSurface *surface);
|
GdkGLContext * gdk_gl_context_new_for_surface (GdkSurface *surface);
|
||||||
|
|
||||||
|
gboolean gdk_gl_context_is_api_allowed (GdkGLContext *self,
|
||||||
|
GdkGLAPI api,
|
||||||
|
GError **error);
|
||||||
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
||||||
gboolean is_legacy);
|
gboolean is_legacy);
|
||||||
|
|
||||||
|
@@ -184,7 +184,10 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
|||||||
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
g_assert (GDK_IS_MACOS_GL_CONTEXT (self));
|
||||||
|
|
||||||
if (self->gl_context != nil)
|
if (self->gl_context != nil)
|
||||||
return TRUE;
|
return GDK_GL_API_GL;
|
||||||
|
|
||||||
|
if (!gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, error))
|
||||||
|
return 0;
|
||||||
|
|
||||||
existing = [NSOpenGLContext currentContext];
|
existing = [NSOpenGLContext currentContext];
|
||||||
|
|
||||||
@@ -197,7 +200,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
|||||||
if (shared != NULL)
|
if (shared != NULL)
|
||||||
{
|
{
|
||||||
if (!(shared_gl_context = get_ns_open_gl_context (GDK_MACOS_GL_CONTEXT (shared), error)))
|
if (!(shared_gl_context = get_ns_open_gl_context (GDK_MACOS_GL_CONTEXT (shared), error)))
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDK_DISPLAY_NOTE (display,
|
GDK_DISPLAY_NOTE (display,
|
||||||
@@ -206,7 +209,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
|||||||
major, minor));
|
major, minor));
|
||||||
|
|
||||||
if (!(pixelFormat = create_pixel_format (major, minor, error)))
|
if (!(pixelFormat = create_pixel_format (major, minor, error)))
|
||||||
return FALSE;
|
return 0;
|
||||||
|
|
||||||
gl_context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
|
gl_context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
|
||||||
shareContext:shared_gl_context];
|
shareContext:shared_gl_context];
|
||||||
@@ -219,7 +222,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
|||||||
GDK_GL_ERROR,
|
GDK_GL_ERROR,
|
||||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
"Failed to create NSOpenGLContext");
|
"Failed to create NSOpenGLContext");
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cgl_context = [gl_context CGLContextObj];
|
cgl_context = [gl_context CGLContextObj];
|
||||||
@@ -258,7 +261,7 @@ gdk_macos_gl_context_real_realize (GdkGLContext *context,
|
|||||||
if (existing != NULL)
|
if (existing != NULL)
|
||||||
[existing makeCurrentContext];
|
[existing makeCurrentContext];
|
||||||
|
|
||||||
return TRUE;
|
return GDK_GL_API_GL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@@ -543,7 +543,7 @@ set_wgl_pixformat_for_hdc (HDC hdc,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static GdkGLAPI
|
||||||
gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@@ -564,6 +564,9 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
|||||||
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
GdkWin32Display *display_win32 = GDK_WIN32_DISPLAY (display);
|
||||||
GdkGLContext *share = gdk_display_get_gl_context (display);
|
GdkGLContext *share = gdk_display_get_gl_context (display);
|
||||||
|
|
||||||
|
if (!gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, error))
|
||||||
|
return 0;
|
||||||
|
|
||||||
gdk_gl_context_get_required_version (context, &major, &minor);
|
gdk_gl_context_get_required_version (context, &major, &minor);
|
||||||
debug_bit = gdk_gl_context_get_debug_enabled (context);
|
debug_bit = gdk_gl_context_get_debug_enabled (context);
|
||||||
compat_bit = gdk_gl_context_get_forward_compatible (context);
|
compat_bit = gdk_gl_context_get_forward_compatible (context);
|
||||||
@@ -589,7 +592,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
|||||||
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
||||||
_("No available configurations for the given pixel format"));
|
_("No available configurations for the given pixel format"));
|
||||||
|
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if there isn't wglCreateContextAttribsARB() on WGL, use a legacy context */
|
/* if there isn't wglCreateContextAttribsARB() on WGL, use a legacy context */
|
||||||
@@ -622,7 +625,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
|||||||
g_set_error_literal (error, GDK_GL_ERROR,
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
_("Unable to create a GL context"));
|
_("Unable to create a GL context"));
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDK_NOTE (OPENGL,
|
GDK_NOTE (OPENGL,
|
||||||
@@ -632,13 +635,10 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
|||||||
|
|
||||||
context_wgl->wgl_context = hglrc;
|
context_wgl->wgl_context = hglrc;
|
||||||
|
|
||||||
/* No GLES, WGL does not support using EGL contexts */
|
|
||||||
gdk_gl_context_set_use_es (context, FALSE);
|
|
||||||
|
|
||||||
/* Ensure that any other context is created with a legacy bit set */
|
/* Ensure that any other context is created with a legacy bit set */
|
||||||
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
||||||
|
|
||||||
return TRUE;
|
return GDK_GL_API_GL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@@ -509,7 +509,7 @@ on_surface_state_changed (GdkGLContext *context)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gboolean
|
static GdkGLAPI
|
||||||
gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@@ -519,8 +519,9 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
|||||||
Display *dpy;
|
Display *dpy;
|
||||||
GdkSurface *surface;
|
GdkSurface *surface;
|
||||||
GdkGLContext *share;
|
GdkGLContext *share;
|
||||||
gboolean debug_bit, compat_bit, legacy_bit, es_bit;
|
gboolean debug_bit, compat_bit, legacy_bit;
|
||||||
int major, minor, flags;
|
int major, minor, flags;
|
||||||
|
GdkGLAPI api = 0;
|
||||||
|
|
||||||
display = gdk_gl_context_get_display (context);
|
display = gdk_gl_context_get_display (context);
|
||||||
dpy = gdk_x11_display_get_xdisplay (display);
|
dpy = gdk_x11_display_get_xdisplay (display);
|
||||||
@@ -536,9 +537,6 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
|||||||
/* If there is no glXCreateContextAttribsARB() then we default to legacy */
|
/* If there is no glXCreateContextAttribsARB() then we default to legacy */
|
||||||
legacy_bit = !display_x11->has_glx_create_context || GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY);
|
legacy_bit = !display_x11->has_glx_create_context || GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY);
|
||||||
|
|
||||||
es_bit = (GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) || (share != NULL && gdk_gl_context_get_use_es (share))) &&
|
|
||||||
(display_x11->has_glx_create_context && display_x11->has_glx_create_es2_context);
|
|
||||||
|
|
||||||
/* We cannot share legacy contexts with core profile ones, so the
|
/* We cannot share legacy contexts with core profile ones, so the
|
||||||
* shared context is the one that decides if we're going to create
|
* shared context is the one that decides if we're going to create
|
||||||
* a legacy context or not.
|
* a legacy context or not.
|
||||||
@@ -553,12 +551,13 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
|||||||
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||||
|
|
||||||
GDK_DISPLAY_NOTE (display, OPENGL,
|
GDK_DISPLAY_NOTE (display, OPENGL,
|
||||||
g_message ("Creating GLX context (GL version:%d.%d, debug:%s, forward:%s, legacy:%s, es:%s)",
|
g_message ("Creating GLX context (GL version:%d.%d, debug:%s, forward:%s, legacy:%s, GL:%s, GLES:%s)",
|
||||||
major, minor,
|
major, minor,
|
||||||
debug_bit ? "yes" : "no",
|
debug_bit ? "yes" : "no",
|
||||||
compat_bit ? "yes" : "no",
|
compat_bit ? "yes" : "no",
|
||||||
legacy_bit ? "yes" : "no",
|
legacy_bit ? "yes" : "no",
|
||||||
es_bit ? "yes" : "no"));
|
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL) ? "yes" : "no",
|
||||||
|
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GLES, NULL) ? "yes" : "no"));
|
||||||
|
|
||||||
/* If we have access to GLX_ARB_create_context_profile then we can ask for
|
/* If we have access to GLX_ARB_create_context_profile then we can ask for
|
||||||
* a compatibility profile; if we don't, then we have to fall back to the
|
* a compatibility profile; if we don't, then we have to fall back to the
|
||||||
@@ -567,16 +566,13 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
|||||||
if (legacy_bit && !GDK_X11_DISPLAY (display)->has_glx_create_context)
|
if (legacy_bit && !GDK_X11_DISPLAY (display)->has_glx_create_context)
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating legacy GL context on request"));
|
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating legacy GL context on request"));
|
||||||
context_glx->glx_context = create_legacy_context (display, display_x11->glx_config, share);
|
/* do it below */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int profile;
|
if (gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
|
||||||
|
{
|
||||||
if (es_bit)
|
int profile = legacy_bit ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
|
||||||
profile = GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
|
||||||
else
|
|
||||||
profile = legacy_bit ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
|
|
||||||
: GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
: GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||||
|
|
||||||
/* We need to tweak the version, otherwise we may end up requesting
|
/* We need to tweak the version, otherwise we may end up requesting
|
||||||
@@ -593,16 +589,32 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
|||||||
context_glx->glx_context = create_gl3_context (display,
|
context_glx->glx_context = create_gl3_context (display,
|
||||||
display_x11->glx_config,
|
display_x11->glx_config,
|
||||||
share,
|
share,
|
||||||
profile, flags, major, minor);
|
profile,
|
||||||
|
flags, major, minor);
|
||||||
|
api = GDK_GL_API_GL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context_glx->glx_context == NULL && !legacy_bit &&
|
||||||
|
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GLES, NULL))
|
||||||
|
{
|
||||||
|
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating GL3 GLES context"));
|
||||||
|
context_glx->glx_context = create_gl3_context (display,
|
||||||
|
display_x11->glx_config,
|
||||||
|
share,
|
||||||
|
GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
|
||||||
|
flags, major, minor);
|
||||||
|
api = GDK_GL_API_GLES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Fall back to legacy in case the GL3 context creation failed */
|
/* Fall back to legacy in case the GL3 context creation failed */
|
||||||
if (context_glx->glx_context == NULL)
|
if (context_glx->glx_context == NULL &&
|
||||||
|
gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, NULL))
|
||||||
{
|
{
|
||||||
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating fallback legacy context"));
|
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Creating fallback legacy context"));
|
||||||
context_glx->glx_context = create_legacy_context (display, display_x11->glx_config, share);
|
context_glx->glx_context = create_legacy_context (display, display_x11->glx_config, share);
|
||||||
legacy_bit = TRUE;
|
legacy_bit = TRUE;
|
||||||
es_bit = FALSE;
|
api = GDK_GL_API_GL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context_glx->glx_context == NULL)
|
if (context_glx->glx_context == NULL)
|
||||||
@@ -610,15 +622,12 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
|||||||
g_set_error_literal (error, GDK_GL_ERROR,
|
g_set_error_literal (error, GDK_GL_ERROR,
|
||||||
GDK_GL_ERROR_NOT_AVAILABLE,
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
||||||
_("Unable to create a GL context"));
|
_("Unable to create a GL context"));
|
||||||
return FALSE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure that any other context is created with a legacy bit set */
|
/* Ensure that any other context is created with a legacy bit set */
|
||||||
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
||||||
|
|
||||||
/* Ensure that any other context is created with an ES bit set */
|
|
||||||
gdk_gl_context_set_use_es (context, es_bit);
|
|
||||||
|
|
||||||
GDK_DISPLAY_NOTE (display, OPENGL,
|
GDK_DISPLAY_NOTE (display, OPENGL,
|
||||||
g_message ("Realized GLX context[%p], %s, version: %d.%d",
|
g_message ("Realized GLX context[%p], %s, version: %d.%d",
|
||||||
context_glx->glx_context,
|
context_glx->glx_context,
|
||||||
@@ -655,7 +664,7 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user