[gtk/wip.win32.fixes: 343/347] gdk/win32: Allow sharing WGL contexts with gstreamer




commit 693d83117fad995cb7718c96665a700cf9eb26f0
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Sat Feb 13 18:40:56 2021 +0800

    gdk/win32: Allow sharing WGL contexts with gstreamer
    
    Add the following to GdkWin32GLContext:
    
    -Explicitly try to request GL 4.1 core profiles, in case the GL driver
     decides to just use the GL version that is passed into the attributes
     used for context creation instead of using the highest available version.
    -Add (private) access to the underlying HGLRC in the GdkGLContext,
     because libepoxy does not allow us to call from the gstreamer media
     backend gdk_gl_context_make_current() directly.

 gdk/win32/gdkglcontext-win32.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gdk/win32/gdkglcontext-win32.c b/gdk/win32/gdkglcontext-win32.c
index c7e7fa3345..153d98c261 100644
--- a/gdk/win32/gdkglcontext-win32.c
+++ b/gdk/win32/gdkglcontext-win32.c
@@ -652,13 +652,26 @@ _create_gl_context (HDC           hdc,
           goto gl_fail;
         }
 
+      /* try to request for a GL 4.1 core profile,
+       * for use with the GL support in the gstreamer media backend,
+       * since some drivers might just request a GL version as is,
+       * without using the max supported version
+       */
       hglrc = _create_gl_context_with_attribs (hdc,
                                                hglrc_base,
                                                share,
                                                flags,
-                                               major,
-                                               minor,
+                                               4,
+                                               1,
                                                is_legacy);
+      if (hglrc == NULL)
+        hglrc = _create_gl_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 */
       if (hglrc == NULL)
@@ -1223,3 +1236,9 @@ _gdk_win32_surface_invalidate_egl_framebuffer (GdkSurface *surface)
     }
 #endif
 }
+
+_GDK_EXTERN
+HGLRC _gdk_win32_gl_context_get_hglrc (GdkGLContext *context)
+{
+  return GDK_WIN32_GL_CONTEXT (context)->hglrc;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]