win32/gl: Use the GdkGLContext options

https://bugzilla.gnome.org/show_bug.cgi?id=741946
This commit is contained in:
Chun-wei Fan 2015-01-30 14:32:26 +08:00 committed by Emmanuele Bassi
parent ba56f11702
commit 4c091db6c2

View File

@ -388,7 +388,12 @@ _gdk_win32_display_init_gl (GdkDisplay *display,
}
static HGLRC
_create_gl_context (HDC hdc, GdkGLContext *share, GdkGLProfile profile)
_create_gl_context (HDC hdc,
GdkGLContext *share,
GdkGLProfile profile,
int flags,
int major,
int minor)
{
HGLRC hglrc;
@ -403,8 +408,9 @@ _create_gl_context (HDC hdc, GdkGLContext *share, GdkGLProfile profile)
gint attribs[] = {
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_MAJOR_VERSION_ARB, major,
WGL_CONTEXT_MINOR_VERSION_ARB, minor,
WGL_CONTEXT_FLAGS_ARB, flags,
0
};
@ -425,7 +431,9 @@ _create_gl_context (HDC hdc, GdkGLContext *share, GdkGLProfile profile)
else
{
/* for legacy WGL, we can't share lists during context creation,
* so do so immediately afterwards
* so do so immediately afterwards.
* The flags, and major and minor versions of WGL to request
* for are ignored for a legacy context.
*/
if (share != NULL)
{
@ -480,18 +488,51 @@ _gdk_win32_gl_context_realize (GdkGLContext *context,
return FALSE;
}
if (profile == GDK_GL_PROFILE_3_2_CORE)
GDK_NOTE (OPENGL, g_print ("Creating core WGL context\n"));
else
{
/* GDK_GL_PROFILE_DEFAULT is the same as GDK_GL_PROFILE_LEGACY for now */
GDK_NOTE (OPENGL, g_print ("Creating legacy WGL context\n"));
if (profile == GDK_GL_PROFILE_DEFAULT)
profile = GDK_GL_PROFILE_LEGACY;
}
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;
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);
profile,
flags,
glver_major,
glver_minor);
}
else
{
GDK_NOTE (OPENGL, g_print ("Creating legacy WGL context\n"));
/* flags, glver_major, glver_minor are ignored unless we are using WGL 3.2+ core contexts */
hglrc = _create_gl_context (context_win32->gl_hdc,
share,
profile,
0, 0, 0);
}
if (hglrc == NULL)
{