mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
gdkglcontext-win32-wgl.c: Cleanup GL context creation
Instead of first trying to explicitly ask for a WGL 4.1 context, ask for the WGL context version that matches what is reported via epoxy_gl_version(), so that we get the maximum WGL version that is supported by the graphics drivers, and make sure any WGL contexts that are shared with this (initial) WGL context are created likewise. We can try to do a default-bog-standard 3.2 core WGL context creation if the need arises, but let's leave that alone for now.
This commit is contained in:
parent
b85aa10700
commit
38c17c1f79
@ -430,33 +430,13 @@ create_wgl_context (HDC hdc,
|
|||||||
goto gl_fail;
|
goto gl_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
hglrc = create_wgl_context_with_attribs (hdc,
|
||||||
* We need a Core GL 4.1 context in order to use the GL support in
|
hglrc_base,
|
||||||
* the GStreamer media widget backend, but wglCreateContextAttribsARB()
|
share,
|
||||||
* may only give us the GL context version that we ask for here, and
|
flags,
|
||||||
* nothing more. So, if we are asking for a pre-GL 4.1 context,
|
major,
|
||||||
* try to ask for a 4.1 context explicitly first. If that is not supported,
|
minor,
|
||||||
* then we fall back to whatever version that we were asking for (or, even a
|
is_legacy);
|
||||||
* legacy context if that fails), at a price of not able to have GL support
|
|
||||||
* for the media GStreamer backend.
|
|
||||||
*/
|
|
||||||
if (major < 4 || (major == 4 && minor < 1))
|
|
||||||
hglrc = create_wgl_context_with_attribs (hdc,
|
|
||||||
hglrc_base,
|
|
||||||
share,
|
|
||||||
flags,
|
|
||||||
4,
|
|
||||||
1,
|
|
||||||
is_legacy);
|
|
||||||
|
|
||||||
if (hglrc == NULL)
|
|
||||||
hglrc = create_wgl_context_with_attribs (hdc,
|
|
||||||
hglrc_base,
|
|
||||||
share,
|
|
||||||
flags,
|
|
||||||
major,
|
|
||||||
minor,
|
|
||||||
is_legacy);
|
|
||||||
|
|
||||||
/* return the legacy context we have if it could be setup properly, in case the 3.0+ context creation failed */
|
/* return the legacy context we have if it could be setup properly, in case the 3.0+ context creation failed */
|
||||||
if (hglrc == NULL)
|
if (hglrc == NULL)
|
||||||
@ -562,10 +542,27 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
|||||||
if (!gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, error))
|
if (!gdk_gl_context_is_api_allowed (context, GDK_GL_API_GL, error))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We may need a Core GL 4.1+ context in order to use the GL support in
|
||||||
|
* the GStreamer media widget backend (such as on Intel drivers), but
|
||||||
|
* wglCreateContextAttribsARB() may only give us the GL context version
|
||||||
|
* that we ask for here, and nothing more. So, improve things here by
|
||||||
|
* asking for the GL version that is reported to us via epoxy_gl_version(),
|
||||||
|
* rather than the default GL core 3.2 context. Save this up in our
|
||||||
|
* GdkGLContext so that subsequent contexts that are shared with this
|
||||||
|
* context are created likewise too.
|
||||||
|
*/
|
||||||
|
if (share != NULL)
|
||||||
|
gdk_gl_context_get_required_version (share, &major, &minor);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
major = display_win32->gl_version / 10;
|
||||||
|
minor = display_win32->gl_version % 10;
|
||||||
|
}
|
||||||
|
|
||||||
if (surface != NULL)
|
if (surface != NULL)
|
||||||
hdc = GDK_WIN32_SURFACE (surface)->hdc;
|
hdc = GDK_WIN32_SURFACE (surface)->hdc;
|
||||||
else
|
else
|
||||||
@ -632,6 +629,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
|
|||||||
|
|
||||||
/* 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);
|
||||||
|
gdk_gl_context_set_required_version (context, major, minor);
|
||||||
|
|
||||||
return GDK_GL_API_GL;
|
return GDK_GL_API_GL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user