[gtk+] win32/gl: Ensure we use the 3.2 core profile
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] win32/gl: Ensure we use the 3.2 core profile
- Date: Tue, 10 Feb 2015 08:21:40 +0000 (UTC)
commit 60195ab021afce26b052213c3145d0dc6b447c0e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Feb 10 16:20:37 2015 +0800
win32/gl: Ensure we use the 3.2 core profile
Emit an error if the profile is different.
This is a follow-up commit to commits cc45e82 (x11/gl: Ensure we use the
3.2 core profile) and 2d9081d (wayland/gl: Ensure we use the 3.2 core
profile), so that we do the same on GDK-Win32. Update variable names and
comments so that the code is clearer to people, as we still need a
temporary legacy WGL context first before we can use
wglCreateContextAttribsARB() to create a WGL core (3.2+) context.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
gdk/win32/gdkglcontext-win32.c | 51 +++++++++++++++------------------------
1 files changed, 20 insertions(+), 31 deletions(-)
---
diff --git a/gdk/win32/gdkglcontext-win32.c b/gdk/win32/gdkglcontext-win32.c
index 7ac610b..4e36c99 100644
--- a/gdk/win32/gdkglcontext-win32.c
+++ b/gdk/win32/gdkglcontext-win32.c
@@ -395,15 +395,14 @@ _create_gl_context (HDC hdc,
int major,
int minor)
{
- HGLRC hglrc;
-
- /* we need a legacy context first, for all cases */
- hglrc = wglCreateContext (hdc);
+ /* we still need a legacy WGL context first for all cases */
+ HGLRC hglrc_base;
- /* Create a WGL 3.2 context, the legacy context *is* needed here */
+ /* Create the WGL Core (3.2+) context, the legacy context *is* needed here */
if (profile == GDK_GL_PROFILE_3_2_CORE)
{
- HGLRC hglrc_32;
+ /* This is the actual WGL context that we want */
+ HGLRC hglrc;
GdkWin32GLContext *context_win32;
gint attribs[] = {
@@ -414,34 +413,25 @@ _create_gl_context (HDC hdc,
0
};
- if (!wglMakeCurrent (hdc, hglrc))
+ hglrc_base = wglCreateContext (hdc);
+
+ if (!wglMakeCurrent (hdc, hglrc_base))
return NULL;
if (share != NULL)
context_win32 = GDK_WIN32_GL_CONTEXT (share);
- hglrc_32 = wglCreateContextAttribsARB (hdc,
- share != NULL ? context_win32->hglrc : NULL,
- attribs);
+ hglrc = wglCreateContextAttribsARB (hdc,
+ share != NULL ? context_win32->hglrc : NULL,
+ attribs);
wglMakeCurrent (NULL, NULL);
- wglDeleteContext (hglrc);
- return hglrc_32;
- }
- else
- {
- /* for legacy WGL, we can't share lists during context creation,
- * 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)
- {
- HGLRC hglrc_shared = GDK_WIN32_GL_CONTEXT (share)->hglrc;
- wglShareLists (hglrc_shared, hglrc);
- }
+ wglDeleteContext (hglrc_base);
return hglrc;
}
+ else
+ /* Should not get here anyways, for now */
+ return NULL;
}
static gboolean
@@ -524,13 +514,12 @@ _gdk_win32_gl_context_realize (GdkGLContext *context,
}
else
{
- GDK_NOTE (OPENGL, g_print ("Creating legacy WGL context\n"));
+ g_set_error_literal (error,
+ GDK_GL_ERROR,
+ GDK_GL_ERROR_UNSUPPORTED_PROFILE,
+ _("Unsupported profile for a GL context"));
- /* 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);
+ return FALSE;
}
if (hglrc == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]