Commit d066e754 authored by Emmanuele Bassi's avatar Emmanuele Bassi

Remove GdkGLProfile

The existence of OpenGL implementations that do not provide the full
core profile compatibility because of reasons beyond the technical, like
llvmpipe not implementing floating point buffers, makes the existence of
GdkGLProfile and documenting the fact that we use core profiles a bit
harder.

Since we do not have any existing profile except the default, we can
remove the GdkGLProfile and its related API from GDK and GTK+, and sweep
the whole thing under the carpet, while we wait for an extension that
lets us ask for the most compatible profile possible.

https://bugzilla.gnome.org/show_bug.cgi?id=744407
parent ccc0eafb
......@@ -1300,9 +1300,6 @@ gdk_gl_context_set_debug_enabled
gdk_gl_context_get_debug_enabled
gdk_gl_context_set_forward_compatible
gdk_gl_context_get_forward_compatible
GdkGLProfile
gdk_gl_context_set_profile
gdk_gl_context_get_profile
<SUBSECTION>
GdkGLError
......
......@@ -91,7 +91,6 @@ typedef struct {
GdkDisplay *display;
GdkWindow *window;
GdkGLContext *shared_context;
GdkGLProfile profile;
int major;
int minor;
......@@ -113,7 +112,6 @@ enum {
PROP_DISPLAY,
PROP_WINDOW,
PROP_PROFILE,
PROP_SHARED_CONTEXT,
LAST_PROP
......@@ -201,10 +199,6 @@ gdk_gl_context_set_property (GObject *gobject,
}
break;
case PROP_PROFILE:
gdk_gl_context_set_profile (GDK_GL_CONTEXT (gobject), g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
......@@ -232,10 +226,6 @@ gdk_gl_context_get_property (GObject *gobject,
g_value_set_object (value, priv->shared_context);
break;
case PROP_PROFILE:
g_value_set_enum (value, priv->profile);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
......@@ -294,22 +284,6 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
/**
* GdkGLContext:profile:
*
* The #GdkGLProfile of the context
*
* Since: 3.16
*/
obj_pspecs[PROP_PROFILE] =
g_param_spec_enum ("profile",
P_("Profile"),
P_("The GL profile the context was created for"),
GDK_TYPE_GL_PROFILE,
GDK_GL_PROFILE_DEFAULT,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
/**
* GdkGLContext:shared-context:
*
......@@ -734,55 +708,6 @@ gdk_gl_context_get_window (GdkGLContext *context)
return priv->window;
}
/**
* gdk_gl_context_set_profile:
* @context: a #GdkGLContext
* @profile: the profile for the context
*
* Sets the profile used when realizing the context.
*
* The #GdkGLContext must not be realized or made current prior to calling
* this function.
*
* Since: 3.16
*/
void
gdk_gl_context_set_profile (GdkGLContext *context,
GdkGLProfile profile)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
g_return_if_fail (!priv->realized);
if (priv->profile != profile)
{
priv->profile = profile;
g_object_notify_by_pspec (G_OBJECT (context), obj_pspecs[PROP_PROFILE]);
}
}
/**
* gdk_gl_context_get_profile:
* @context: a #GdkGLContext
*
* Retrieves the #GdkGLProfile set using gdk_gl_context_set_profile().
*
* Returns: a #GdkGLProfile
*
* Since: 3.16
*/
GdkGLProfile
gdk_gl_context_get_profile (GdkGLContext *context)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), GDK_GL_PROFILE_DEFAULT);
return priv->profile;
}
/**
* gdk_gl_context_get_shared_context:
* @context: a #GdkGLContext
......
......@@ -71,11 +71,6 @@ 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_16
void gdk_gl_context_set_profile (GdkGLContext *context,
GdkGLProfile profile);
GDK_AVAILABLE_IN_3_16
GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context);
GDK_AVAILABLE_IN_3_16
gboolean gdk_gl_context_realize (GdkGLContext *context,
......
......@@ -433,22 +433,6 @@ struct _GdkPoint
gint y;
};
/**
* GdkGLProfile:
* @GDK_GL_PROFILE_DEFAULT: The default profile.
* @GDK_GL_PROFILE_3_2_CORE: Use the OpenGL core profile, with
* a minimum required version of 3.2; this is the default
* profile.
*
* The profile to be used when creating a #GdkGLContext.
*
* Since: 3.16
*/
typedef enum {
GDK_GL_PROFILE_DEFAULT,
GDK_GL_PROFILE_3_2_CORE
} GdkGLProfile;
/**
* GdkGLError:
* @GDK_GL_ERROR_NOT_AVAILABLE: OpenGL support is not available
......
......@@ -35,7 +35,6 @@ gdk_mir_gl_context_realize (GdkGLContext *context,
GdkMirGLContext *context_mir = GDK_MIR_GL_CONTEXT (context);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
GdkGLProfile profile = gdk_gl_context_get_profile (context);
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS];
int major, minor, flags;
......@@ -50,18 +49,6 @@ gdk_mir_gl_context_realize (GdkGLContext *context,
return FALSE;
}
/* "default profile" means 3.2 core profile */
if (profile == GDK_GL_PROFILE_DEFAULT)
profile = GDK_GL_PROFILE_3_2_CORE;
if (profile != GDK_GL_PROFILE_3_2_CORE)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("Unsupported profile for a GL context"));
return FALSE;
}
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
forward_bit = gdk_gl_context_get_forward_compatible (context);
......
......@@ -109,7 +109,6 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
GdkDisplay *display = gdk_gl_context_get_display (context);
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
GdkGLProfile profile = gdk_gl_context_get_profile (context);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLContext ctx;
EGLint context_attribs[N_EGL_ATTRS];
......@@ -117,18 +116,6 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
gboolean debug_bit, forward_bit;
int i = 0;
/* default profile means 3.2 core profile */
if (profile == GDK_GL_PROFILE_DEFAULT)
profile = GDK_GL_PROFILE_3_2_CORE;
if (profile != GDK_GL_PROFILE_3_2_CORE)
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("Unsupported profile for a GL context"));
return FALSE;
}
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
forward_bit = gdk_gl_context_get_forward_compatible (context);
......@@ -386,7 +373,7 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("3.2 core GL profile is not available on EGL implementation"));
_("Core GL is not available on EGL implementation"));
return NULL;
}
......
......@@ -390,48 +390,40 @@ _gdk_win32_display_init_gl (GdkDisplay *display,
static HGLRC
_create_gl_context (HDC hdc,
GdkGLContext *share,
GdkGLProfile profile,
int flags,
int major,
int minor)
{
/* we still need a legacy WGL context first for all cases */
HGLRC hglrc_base;
/* This is the actual WGL context that we want */
HGLRC hglrc;
GdkWin32GLContext *context_win32;
/* Create the WGL Core (3.2+) context, the legacy context *is* needed here */
if (profile == GDK_GL_PROFILE_3_2_CORE)
{
/* This is the actual WGL context that we want */
HGLRC hglrc;
GdkWin32GLContext *context_win32;
gint attribs[] = {
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_MAJOR_VERSION_ARB, major,
WGL_CONTEXT_MINOR_VERSION_ARB, minor,
WGL_CONTEXT_FLAGS_ARB, flags,
0
};
gint attribs[] = {
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_MAJOR_VERSION_ARB, major,
WGL_CONTEXT_MINOR_VERSION_ARB, minor,
WGL_CONTEXT_FLAGS_ARB, flags,
0
};
hglrc_base = wglCreateContext (hdc);
hglrc_base = wglCreateContext (hdc);
if (!wglMakeCurrent (hdc, hglrc_base))
return NULL;
if (!wglMakeCurrent (hdc, hglrc_base))
return NULL;
if (share != NULL)
context_win32 = GDK_WIN32_GL_CONTEXT (share);
if (share != NULL)
context_win32 = GDK_WIN32_GL_CONTEXT (share);
hglrc = wglCreateContextAttribsARB (hdc,
share != NULL ? context_win32->hglrc : NULL,
attribs);
hglrc = wglCreateContextAttribsARB (hdc,
share != NULL ? context_win32->hglrc : NULL,
attribs);
wglMakeCurrent (NULL, NULL);
wglDeleteContext (hglrc_base);
wglMakeCurrent (NULL, NULL);
wglDeleteContext (hglrc_base);
return hglrc;
}
else
/* Should not get here anyways, for now */
return NULL;
return hglrc;
}
static gboolean
......@@ -460,12 +452,12 @@ _gdk_win32_gl_context_realize (GdkGLContext *context,
GError **error)
{
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
GdkGLProfile profile = gdk_gl_context_get_profile (context);
GdkWin32GLContext *context_win32 = GDK_WIN32_GL_CONTEXT (context);
/* These are the real WGL context items that we will want to use later */
HGLRC hglrc;
gint pixel_format;
gboolean debug_bit, compat_bit;
if (!_set_pixformat_for_hdc (context_win32->gl_hdc,
&pixel_format,
......@@ -477,50 +469,32 @@ _gdk_win32_gl_context_realize (GdkGLContext *context,
return FALSE;
}
if (profile == GDK_GL_PROFILE_DEFAULT)
profile = GDK_GL_PROFILE_3_2_CORE;
if (profile == GDK_GL_PROFILE_3_2_CORE)
{
gboolean debug_bit, compat_bit;
/* request flags and specific versions for core (3.2+) WGL context */
gint flags = 0;
gint glver_major = 0;
gint glver_minor = 0;
gdk_gl_context_get_required_version (context, &glver_major, &glver_minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);
if (debug_bit)
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
if (compat_bit)
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
/* request flags and specific versions for core (3.2+) WGL context */
gint flags = 0;
gint glver_major = 0;
gint glver_minor = 0;
GDK_NOTE (OPENGL,
g_print ("Creating core WGL context (version:%d.%d, debug:%s, forward:%s)\n",
major, minor,
debug_bit ? "yes" : "no",
compat_bit ? "yes" : "no"));
hglrc = _create_gl_context (context_win32->gl_hdc,
share,
profile,
flags,
glver_major,
glver_minor);
}
else
{
g_set_error_literal (error,
GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("Unsupported profile for a GL context"));
gdk_gl_context_get_required_version (context, &glver_major, &glver_minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);
return FALSE;
}
if (debug_bit)
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
if (compat_bit)
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
GDK_NOTE (OPENGL,
g_print ("Creating core WGL context (version:%d.%d, debug:%s, forward:%s)\n",
major, minor,
debug_bit ? "yes" : "no",
compat_bit ? "yes" : "no"));
hglrc = _create_gl_context (context_win32->gl_hdc,
share,
flags,
glver_major,
glver_minor);
if (hglrc == NULL)
{
g_set_error_literal (error, GDK_GL_ERROR,
......@@ -575,7 +549,7 @@ _gdk_win32_window_create_gl_context (GdkWindow *window,
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("The WGL_ARB_create_context extension "
"needed to create 3.2 core profiles is not "
"needed to create core profiles is not "
"available"));
return NULL;
}
......
......@@ -581,59 +581,37 @@ gdk_x11_gl_context_realize (GdkGLContext *context,
XVisualInfo *xvisinfo;
Display *dpy;
DrawableInfo *info;
GdkGLProfile profile;
GdkGLContext *share;
GdkWindow *window;
gboolean debug_bit, compat_bit;
int major, minor, flags;
window = gdk_gl_context_get_window (context);
display = gdk_window_get_display (window);
dpy = gdk_x11_display_get_xdisplay (display);
context_x11 = GDK_X11_GL_CONTEXT (context);
profile = gdk_gl_context_get_profile (context);
share = gdk_gl_context_get_shared_context (context);
/* default means 3.2 core profile */
if (profile == GDK_GL_PROFILE_DEFAULT)
profile = GDK_GL_PROFILE_3_2_CORE;
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);
/* we check for the presence of the GLX_ARB_create_context_profile
* extension before checking for a GLXFBConfig when creating the
* GdkX11GLContext instance in gdk_x11_window_create_gl_context().
*/
if (profile == GDK_GL_PROFILE_3_2_CORE)
{
gboolean debug_bit, compat_bit;
int major, minor, flags;
gdk_gl_context_get_required_version (context, &major, &minor);
debug_bit = gdk_gl_context_get_debug_enabled (context);
compat_bit = gdk_gl_context_get_forward_compatible (context);
flags = 0;
if (debug_bit)
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
if (compat_bit)
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
GDK_NOTE (OPENGL,
g_print ("Creating core GLX context (version:%d.%d, debug:%s, forward:%s)\n",
major, minor,
debug_bit ? "yes" : "no",
compat_bit ? "yes" : "no"));
context_x11->glx_context = create_gl3_context (display,
context_x11->glx_config,
share,
flags, major, minor);
}
else
{
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("Unsupported profile for a GL context"));
return FALSE;
}
flags = 0;
if (debug_bit)
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
if (compat_bit)
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
GDK_NOTE (OPENGL,
g_print ("Creating core GLX context (version:%d.%d, debug:%s, forward:%s)\n",
major, minor,
debug_bit ? "yes" : "no",
compat_bit ? "yes" : "no"));
context_x11->glx_context = create_gl3_context (display,
context_x11->glx_config,
share,
flags, major, minor);
if (context_x11->glx_context == NULL)
{
g_set_error_literal (error, GDK_GL_ERROR,
......@@ -1191,8 +1169,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
g_set_error_literal (error, GDK_GL_ERROR,
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
_("The GLX_ARB_create_context_profile extension "
"needed to create 3.2 core profiles is not "
"available"));
"needed to create core profiles is not available"));
return NULL;
}
......
......@@ -40,7 +40,6 @@ struct _GdkX11GLContext
{
GdkGLContext parent_instance;
GdkGLProfile profile;
GLXContext glx_context;
GLXFBConfig glx_config;
GLXDrawable drawable;
......
......@@ -98,7 +98,6 @@
*/
typedef struct {
GdkGLProfile profile;
GdkGLContext *context;
GdkWindow *event_window;
GError *error;
......@@ -125,7 +124,6 @@ enum {
PROP_0,
PROP_CONTEXT,
PROP_PROFILE,
PROP_HAS_ALPHA,
PROP_HAS_DEPTH_BUFFER,
PROP_HAS_STENCIL_BUFFER,
......@@ -188,10 +186,6 @@ gtk_gl_area_set_property (GObject *gobject,
gtk_gl_area_set_has_stencil_buffer (self, g_value_get_boolean (value));
break;
case PROP_PROFILE:
gtk_gl_area_set_profile (self, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
......@@ -227,10 +221,6 @@ gtk_gl_area_get_property (GObject *gobject,
g_value_set_object (value, priv->context);
break;
case PROP_PROFILE:
g_value_set_enum (value, priv->profile);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
......@@ -312,7 +302,6 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
gdk_gl_context_set_required_version (context,
priv->required_gl_version / 10,
priv->required_gl_version % 10);
gdk_gl_context_set_profile (context, priv->profile);
gdk_gl_context_realize (context, &error);
if (priv->error != NULL)
......@@ -735,24 +724,6 @@ gtk_gl_area_class_init (GtkGLAreaClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
/**
* GdkGLArea:profile:
*
* The #GdkGLProfile to use to create the GL context for the area.
*
* Since: 3.16
*/
obj_props[PROP_PROFILE] =
g_param_spec_enum ("profile",
P_("Profile"),
P_("The GL profile to use for the GL context"),
GDK_TYPE_GL_PROFILE,
GDK_GL_PROFILE_DEFAULT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
/**
* GtkGLArea:auto-render:
*
......@@ -899,7 +870,7 @@ gtk_gl_area_class_init (GtkGLAreaClass *klass)
* realized, and allows you to override how the GL context is
* created. This is useful when you want to reuse an existing GL
* context, or if you want to try creating different kinds of GL
* profiles.
* options.
*
* If context creation fails then the signal handler can use
* gtk_gl_area_set_error() to register a more detailed error
......@@ -928,7 +899,6 @@ gtk_gl_area_init (GtkGLArea *area)
gtk_widget_set_has_window (GTK_WIDGET (area), FALSE);
gtk_widget_set_app_paintable (GTK_WIDGET (area), TRUE);
priv->profile = GDK_GL_PROFILE_DEFAULT;
priv->auto_render = TRUE;
priv->needs_render = TRUE;
priv->required_gl_version = 0;
......@@ -1043,54 +1013,6 @@ gtk_gl_area_get_required_version (GtkGLArea *area,
*minor = priv->required_gl_version % 10;
}
/**
* gtk_gl_area_get_profile:
* @area: a #GtkGLArea
*
* Returns the profile that will be used to create the GL context for the area.
*
* Returns: a #GdkGLProfile
*
* Since: 3.16
*/
GdkGLProfile
gtk_gl_area_get_profile (GtkGLArea *area)
{
GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
g_return_val_if_fail (GTK_IS_GL_AREA (area), FALSE);
return priv->profile;
}
/**
* gtk_gl_area_set_profile:
* @area: a #GtkGLArea
* @profile: a #GdkGLProfile
*
* Sets the profile type to be used when creating the context for the widget.
*
* This function must be called before the area has been realized.
*
* Since: 3.16
*/
void
gtk_gl_area_set_profile (GtkGLArea *area,
GdkGLProfile profile)
{
GtkGLAreaPrivate *priv = gtk_gl_area_get_instance_private (area);
g_return_if_fail (GTK_IS_GL_AREA (area));
g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (area)));
if (priv->profile != profile)
{
priv->profile = profile;
g_object_notify (G_OBJECT (area), "profile");
}
}
/**
* gtk_gl_area_get_has_alpha:
* @area: a #GtkGLArea
......
......@@ -92,11 +92,6 @@ void gtk_gl_area_get_required_version (GtkGLArea *area,
int *major,
int *minor);
GDK_AVAILABLE_IN_3_16
GdkGLProfile gtk_gl_area_get_profile (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_profile (GtkGLArea *area,
GdkGLProfile profile);
GDK_AVAILABLE_IN_3_16
gboolean gtk_gl_area_get_has_alpha (GtkGLArea *area);
GDK_AVAILABLE_IN_3_16
void gtk_gl_area_set_has_alpha (GtkGLArea *area,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment