forked from AuroraMiddleware/gtk
gl: Add 'use-es' flag
On some platforms we can ask the GL context machinery to create a GLES context, instead of a GL one. In order to ask for a GLES context at GdkGLContext realization time, we use a bit field like we do for forward compatible, or debug contexts. The 'use-es' bit also changes the way we select a default version, because OpenGL and OpenGLES versions differ. https://bugzilla.gnome.org/show_bug.cgi?id=743746
This commit is contained in:
parent
6225d435e6
commit
e1cecd243a
@ -104,6 +104,7 @@ typedef struct {
|
||||
guint debug_enabled : 1;
|
||||
guint forward_compatible : 1;
|
||||
guint is_legacy : 1;
|
||||
guint use_es : 1;
|
||||
|
||||
GdkGLContextPaintData *paint_data;
|
||||
} GdkGLContextPrivate;
|
||||
@ -496,8 +497,8 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
|
||||
int major,
|
||||
int minor)
|
||||
{
|
||||
int version;
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
int version, min_ver;
|
||||
|
||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||
g_return_if_fail (!priv->realized);
|
||||
@ -512,10 +513,16 @@ gdk_gl_context_set_required_version (GdkGLContext *context,
|
||||
|
||||
/* Enforce a minimum context version number of 3.2 */
|
||||
version = (major * 100) + minor;
|
||||
if (version < 302)
|
||||
|
||||
if (!priv->use_es)
|
||||
min_ver = 302;
|
||||
else
|
||||
min_ver = 200;
|
||||
|
||||
if (version < min_ver)
|
||||
{
|
||||
g_warning ("gdk_gl_context_set_required_version - GL context versions less than 3.2 are not supported.");
|
||||
version = 302;
|
||||
version = min_ver;
|
||||
}
|
||||
priv->major = version / 100;
|
||||
priv->minor = version % 100;
|
||||
@ -538,19 +545,31 @@ gdk_gl_context_get_required_version (GdkGLContext *context,
|
||||
int *minor)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
int default_major, default_minor;
|
||||
int maj, min;
|
||||
|
||||
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
|
||||
|
||||
if (!priv->use_es)
|
||||
{
|
||||
default_major = 3;
|
||||
default_minor = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
default_major = 2;
|
||||
default_minor = 0;
|
||||
}
|
||||
|
||||
if (priv->major > 0)
|
||||
maj = priv->major;
|
||||
else
|
||||
maj = 3;
|
||||
maj = default_major;
|
||||
|
||||
if (priv->minor > 0)
|
||||
min = priv->minor;
|
||||
else
|
||||
min = 2;
|
||||
min = default_minor;
|
||||
|
||||
if (major != NULL)
|
||||
*major = maj;
|
||||
@ -603,6 +622,23 @@ gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
||||
priv->is_legacy = !!is_legacy;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_gl_context_set_use_es (GdkGLContext *context,
|
||||
gboolean use_es)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
priv->use_es = !!use_es;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_gl_context_get_use_es (GdkGLContext *context)
|
||||
{
|
||||
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
|
||||
|
||||
return priv->use_es;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_gl_context_realize:
|
||||
* @context: a #GdkGLContext
|
||||
|
@ -73,6 +73,11 @@ void gdk_gl_context_set_forward_compatible (GdkGLContext *
|
||||
gboolean compatible);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
gboolean gdk_gl_context_get_forward_compatible (GdkGLContext *context);
|
||||
GDK_AVAILABLE_IN_3_22
|
||||
void gdk_gl_context_set_use_es (GdkGLContext *context,
|
||||
gboolean use_es);
|
||||
GDK_AVAILABLE_IN_3_22
|
||||
gboolean gdk_gl_context_get_use_es (GdkGLContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
gboolean gdk_gl_context_realize (GdkGLContext *context,
|
||||
|
@ -69,6 +69,7 @@ typedef struct {
|
||||
GdkGLContextProgram *current_program;
|
||||
|
||||
guint is_legacy : 1;
|
||||
guint use_es : 1;
|
||||
} GdkGLContextPaintData;
|
||||
|
||||
void gdk_gl_context_set_is_legacy (GdkGLContext *context,
|
||||
|
Loading…
Reference in New Issue
Block a user