forked from AuroraMiddleware/gtk
gl: Drop profile for gdk_window_create_gl_context()
Now that we have a two-stages GL context creation sequence, we can move the profile to a pre-realize option, like the debug and forward compatibility bits, or the GL version to use.
This commit is contained in:
parent
015bf99816
commit
022724aa69
@ -201,7 +201,7 @@ gdk_gl_context_set_property (GObject *gobject,
|
||||
break;
|
||||
|
||||
case PROP_PROFILE:
|
||||
priv->profile = g_value_get_enum (value);
|
||||
gdk_gl_context_set_profile (GDK_GL_CONTEXT (gobject), g_value_get_enum (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -307,7 +307,6 @@ gdk_gl_context_class_init (GdkGLContextClass *klass)
|
||||
GDK_TYPE_GL_PROFILE,
|
||||
GDK_GL_PROFILE_DEFAULT,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
@ -730,11 +729,40 @@ 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 that @context was created for.
|
||||
* Retrieves the #GdkGLProfile set using gdk_gl_context_set_profile().
|
||||
*
|
||||
* Returns: a #GdkGLProfile
|
||||
*
|
||||
|
@ -47,8 +47,6 @@ GdkDisplay * gdk_gl_context_get_display (GdkGLContext *
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkWindow * gdk_gl_context_get_window (GdkGLContext *context);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkGLProfile gdk_gl_context_get_profile (GdkGLContext *context);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkGLContext * gdk_gl_context_get_shared_context (GdkGLContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
@ -69,11 +67,15 @@ 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,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gdk_gl_context_make_current (GdkGLContext *context);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
|
@ -2742,7 +2742,6 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
|
||||
window->impl_window->gl_paint_context =
|
||||
GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window->impl_window,
|
||||
TRUE,
|
||||
GDK_GL_PROFILE_DEFAULT,
|
||||
NULL,
|
||||
&internal_error);
|
||||
}
|
||||
@ -2768,7 +2767,6 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
|
||||
/**
|
||||
* gdk_window_create_gl_context:
|
||||
* @window: a #GdkWindow
|
||||
* @profile: the GL profile the context should target
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Creates a new #GdkGLContext matching the
|
||||
@ -2778,7 +2776,7 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
|
||||
* If the creation of the #GdkGLContext failed, @error will be set.
|
||||
*
|
||||
* Before using the returned #GdkGLContext, you will need to
|
||||
* call gdk_gl_context_make_current().
|
||||
* call gdk_gl_context_make_current() or gdk_gl_context_realize().
|
||||
*
|
||||
* Returns: (transfer full): the newly created #GdkGLContext, or
|
||||
* %NULL on error
|
||||
@ -2787,7 +2785,6 @@ gdk_window_get_paint_gl_context (GdkWindow *window,
|
||||
**/
|
||||
GdkGLContext *
|
||||
gdk_window_create_gl_context (GdkWindow *window,
|
||||
GdkGLProfile profile,
|
||||
GError **error)
|
||||
{
|
||||
GdkGLContext *paint_context;
|
||||
@ -2801,7 +2798,6 @@ gdk_window_create_gl_context (GdkWindow *window,
|
||||
|
||||
return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->create_gl_context (window->impl_window,
|
||||
FALSE,
|
||||
profile,
|
||||
paint_context,
|
||||
error);
|
||||
}
|
||||
|
@ -1113,7 +1113,6 @@ gboolean gdk_window_show_window_menu (GdkWindow *window,
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkGLContext * gdk_window_create_gl_context (GdkWindow *window,
|
||||
GdkGLProfile profile,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -293,7 +293,6 @@ struct _GdkWindowImplClass
|
||||
GdkEvent *event);
|
||||
GdkGLContext *(*create_gl_context) (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error);
|
||||
gboolean (* realize_gl_context) (GdkWindow *window,
|
||||
|
@ -50,6 +50,10 @@ 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,
|
||||
|
@ -1392,7 +1392,6 @@ find_eglconfig_for_window (GdkWindow *window,
|
||||
static GdkGLContext *
|
||||
gdk_mir_window_impl_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error)
|
||||
{
|
||||
@ -1408,11 +1407,7 @@ gdk_mir_window_impl_create_gl_context (GdkWindow *window,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (profile == GDK_GL_PROFILE_DEFAULT)
|
||||
profile = GDK_GL_PROFILE_3_2_CORE;
|
||||
|
||||
if (profile == GDK_GL_PROFILE_3_2_CORE &&
|
||||
!_gdk_mir_display_have_egl_khr_create_context (display))
|
||||
if (!_gdk_mir_display_have_egl_khr_create_context (display))
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||
@ -1426,7 +1421,6 @@ gdk_mir_window_impl_create_gl_context (GdkWindow *window,
|
||||
context = g_object_new (GDK_TYPE_MIR_GL_CONTEXT,
|
||||
"display", display,
|
||||
"window", window,
|
||||
"profile", profile,
|
||||
"shared-context", share,
|
||||
NULL);
|
||||
|
||||
|
@ -117,6 +117,10 @@ 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,
|
||||
@ -362,7 +366,6 @@ find_eglconfig_for_window (GdkWindow *window,
|
||||
GdkGLContext *
|
||||
gdk_wayland_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error)
|
||||
{
|
||||
@ -379,11 +382,7 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (profile == GDK_GL_PROFILE_DEFAULT)
|
||||
profile = GDK_GL_PROFILE_3_2_CORE;
|
||||
|
||||
if (profile == GDK_GL_PROFILE_3_2_CORE &&
|
||||
!display_wayland->have_egl_khr_create_context)
|
||||
if (!display_wayland->have_egl_khr_create_context)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||
@ -397,7 +396,6 @@ gdk_wayland_window_create_gl_context (GdkWindow *window,
|
||||
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
|
||||
"display", display,
|
||||
"window", window,
|
||||
"profile", profile,
|
||||
"shared-context", share,
|
||||
NULL);
|
||||
|
||||
|
@ -50,7 +50,6 @@ struct _GdkWaylandGLContextClass
|
||||
gboolean gdk_wayland_display_init_gl (GdkDisplay *display);
|
||||
GdkGLContext * gdk_wayland_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attach,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error);
|
||||
void gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
|
@ -461,7 +461,6 @@ _gdk_win32_gl_context_realize (GdkGLContext *context,
|
||||
{
|
||||
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 */
|
||||
@ -543,7 +542,6 @@ _gdk_win32_gl_context_realize (GdkGLContext *context,
|
||||
GdkGLContext *
|
||||
_gdk_win32_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error)
|
||||
{
|
||||
@ -572,9 +570,7 @@ _gdk_win32_window_create_gl_context (GdkWindow *window,
|
||||
}
|
||||
|
||||
/* We first check whether we have WGL_ARB_create_context... */
|
||||
|
||||
if (profile == GDK_GL_PROFILE_3_2_CORE &&
|
||||
!display_win32->hasWglARBCreateContext)
|
||||
if (!display_win32->hasWglARBCreateContext)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||
@ -593,7 +589,6 @@ _gdk_win32_window_create_gl_context (GdkWindow *window,
|
||||
context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT,
|
||||
"display", display,
|
||||
"window", window,
|
||||
"profile", profile,
|
||||
"shared-context", share,
|
||||
NULL);
|
||||
|
||||
|
@ -56,7 +56,6 @@ struct _GdkWin32GLContextClass
|
||||
GdkGLContext *
|
||||
_gdk_win32_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error);
|
||||
|
||||
|
@ -592,8 +592,13 @@ gdk_x11_gl_context_realize (GdkGLContext *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;
|
||||
|
||||
/* we check for the presence of the GLX_ARB_create_context_profile
|
||||
* extension before checking for a GLXFBConfig.
|
||||
* 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)
|
||||
{
|
||||
@ -1163,7 +1168,6 @@ _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen)
|
||||
GdkGLContext *
|
||||
gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error)
|
||||
{
|
||||
@ -1174,10 +1178,6 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
|
||||
/* GDK_GL_PROFILE_DEFAULT is currently equivalent to the 3_2_CORE profile */
|
||||
if (profile == GDK_GL_PROFILE_DEFAULT)
|
||||
profile = GDK_GL_PROFILE_3_2_CORE;
|
||||
|
||||
if (!gdk_x11_screen_init_gl (gdk_window_get_screen (window)))
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
@ -1186,8 +1186,7 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (profile == GDK_GL_PROFILE_3_2_CORE &&
|
||||
!GDK_X11_DISPLAY (display)->has_glx_create_context)
|
||||
if (!GDK_X11_DISPLAY (display)->has_glx_create_context)
|
||||
{
|
||||
g_set_error_literal (error, GDK_GL_ERROR,
|
||||
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
||||
@ -1204,11 +1203,9 @@ gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
context = g_object_new (GDK_TYPE_X11_GL_CONTEXT,
|
||||
"display", display,
|
||||
"window", window,
|
||||
"profile", profile,
|
||||
"shared-context", share,
|
||||
NULL);
|
||||
|
||||
context->profile = profile;
|
||||
context->glx_config = config;
|
||||
context->is_attached = attached;
|
||||
|
||||
|
@ -60,7 +60,6 @@ struct _GdkX11GLContextClass
|
||||
gboolean gdk_x11_screen_init_gl (GdkScreen *screen);
|
||||
GdkGLContext * gdk_x11_window_create_gl_context (GdkWindow *window,
|
||||
gboolean attached,
|
||||
GdkGLProfile profile,
|
||||
GdkGLContext *share,
|
||||
GError **error);
|
||||
void gdk_x11_window_invalidate_for_new_frame (GdkWindow *window,
|
||||
|
@ -322,7 +322,7 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
|
||||
GError *error = NULL;
|
||||
GdkGLContext *context;
|
||||
|
||||
context = gdk_window_create_gl_context (gtk_widget_get_window (widget), priv->profile, &error);
|
||||
context = gdk_window_create_gl_context (gtk_widget_get_window (widget), &error);
|
||||
if (priv->error != NULL)
|
||||
{
|
||||
gtk_gl_area_set_error (area, error);
|
||||
@ -330,6 +330,8 @@ gtk_gl_area_real_create_context (GtkGLArea *area)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gdk_gl_context_set_profile (context, priv->profile);
|
||||
|
||||
gdk_gl_context_realize (context, &error);
|
||||
if (priv->error != NULL)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user