win32: Pass the version properly through the creation stack
authorBenjamin Otte <otte@redhat.com>
Tue, 25 Apr 2023 19:30:32 +0000 (21:30 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 27 Apr 2023 00:13:32 +0000 (02:13 +0200)
We were using major/minor instead of GdkGLVersion.

And we were resetting back to 0 and ignoring the required min version
which we should not do.

gdk/win32/gdkglcontext-win32-wgl.c

index 80995fdcce283c013b336a57a17dc761a476e5b9..60097ecd0180ff7e749d4d63fdd8e626fa7d9d06 100644 (file)
@@ -340,8 +340,7 @@ create_wgl_context_with_attribs (HDC           hdc,
                                  HGLRC         hglrc_base,
                                  GdkGLContext *share,
                                  int           flags,
-                                 int           major,
-                                 int           minor,
+                                 GdkGLVersion *version,
                                  gboolean     *is_legacy)
 {
   HGLRC hglrc;
@@ -356,8 +355,8 @@ create_wgl_context_with_attribs (HDC           hdc,
 
   int attribs[] = {
     WGL_CONTEXT_PROFILE_MASK_ARB,   profile,
-    WGL_CONTEXT_MAJOR_VERSION_ARB, *is_legacy ? 3 : major,
-    WGL_CONTEXT_MINOR_VERSION_ARB, *is_legacy ? 0 : minor,
+    WGL_CONTEXT_MAJOR_VERSION_ARB,  gdk_gl_version_get_major (version),
+    WGL_CONTEXT_MINOR_VERSION_ARB,  gdk_gl_version_get_minor (version),
     WGL_CONTEXT_FLAGS_ARB,          flags,
     0
   };
@@ -373,13 +372,12 @@ create_wgl_context_with_attribs (HDC           hdc,
 }
 
 static HGLRC
-create_wgl_context (HDC           hdc,
-                    GdkGLContext *share,
-                    int           flags,
-                    int           major,
-                    int           minor,
-                    gboolean     *is_legacy,
-                    gboolean      hasWglARBCreateContext)
+create_wgl_context (HDC                 hdc,
+                    GdkGLContext       *share,
+                    int                 flags,
+                    GdkGLVersion       *version,
+                    gboolean           *is_legacy,
+                    gboolean            hasWglARBCreateContext)
 {
   /* We need a legacy context for *all* cases */
   HGLRC hglrc_base = wglCreateContext (hdc);
@@ -415,8 +413,7 @@ create_wgl_context (HDC           hdc,
                                                hglrc_base,
                                                share,
                                                flags,
-                                               major,
-                                               minor,
+                                               version,
                                                is_legacy);
 
       /* return the legacy context we have if it could be setup properly, in case the 3.0+ context creation failed */
@@ -429,7 +426,7 @@ create_wgl_context (HDC           hdc,
                                                        hglrc_base,
                                                        share,
                                                        flags,
-                                                       0, 0,
+                                                       version,
                                                        is_legacy);
 
               *is_legacy = TRUE;
@@ -581,8 +578,7 @@ gdk_win32_gl_context_wgl_realize (GdkGLContext *context,
   hglrc = create_wgl_context (hdc,
                               share,
                               flags,
-                              gdk_gl_version_get_major (&version),
-                              gdk_gl_version_get_minor (&version),
+                              &version,
                               &legacy_bit,
                               display_win32->hasWglARBCreateContext);