[vlc-commits] wgl: add getExtensionsString callback

Thomas Guillem git at videolan.org
Mon Nov 13 13:12:16 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Nov  8 16:38:10 2017 +0100| [1d68b84bc8a4f061a786645e1346605a26e820de] | committer: Thomas Guillem

wgl: add getExtensionsString callback

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d68b84bc8a4f061a786645e1346605a26e820de
---

 include/vlc_opengl.h             |  6 ++++++
 modules/video_output/win32/wgl.c | 31 +++++++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
index 8e53a8a7fa..fdebfeb2e1 100644
--- a/include/vlc_opengl.h
+++ b/include/vlc_opengl.h
@@ -54,6 +54,7 @@ struct vlc_gl_t
     enum {
         VLC_GL_EXT_DEFAULT,
         VLC_GL_EXT_EGL,
+        VLC_GL_EXT_WGL,
     } ext;
 
     union {
@@ -68,6 +69,11 @@ struct vlc_gl_t
             /* call eglDestroyImageKHR() with current display, can be NULL */
             bool (*destroyImageKHR)(vlc_gl_t *, void *image);
         } egl;
+        /* if ext == VLC_GL_EXT_WGL */
+        struct
+        {
+            const char *(*getExtensionsString)(vlc_gl_t *);
+        } wgl;
     };
 };
 
diff --git a/modules/video_output/win32/wgl.c b/modules/video_output/win32/wgl.c
index d3ffada8df..72a9cc4c51 100644
--- a/modules/video_output/win32/wgl.c
+++ b/modules/video_output/win32/wgl.c
@@ -66,12 +66,19 @@ struct vout_display_sys_t
     HGLRC                 hGLRC;
     vlc_gl_t              *gl;
     HDC                   affinityHDC; // DC for the selected GPU
+
+    struct
+    {
+        PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
+        PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
+    } exts;
 };
 
 static void          Swap(vlc_gl_t *);
 static void          *OurGetProcAddress(vlc_gl_t *, const char *);
 static int           MakeCurrent(vlc_gl_t *gl);
 static void          ReleaseCurrent(vlc_gl_t *gl);
+static const char *  GetExtensionsString(vlc_gl_t *gl);
 
 #define VLC_PFD_INITIALIZER { \
     .nSize = sizeof(PIXELFORMATDESCRIPTOR), \
@@ -187,8 +194,8 @@ static int Open(vlc_object_t *object)
         goto error;
     }
 
-#ifdef WGL_EXT_swap_control
     wglMakeCurrent(sys->hGLDC, sys->hGLRC);
+#ifdef WGL_EXT_swap_control
     /* Create an GPU Affinity DC */
     const char *extensions = (const char*)glGetString(GL_EXTENSIONS);
     if (HasExtension(extensions, "WGL_EXT_swap_control")) {
@@ -196,15 +203,27 @@ static int Open(vlc_object_t *object)
         if (SwapIntervalEXT)
             SwapIntervalEXT(1);
     }
-    wglMakeCurrent(sys->hGLDC, NULL);
 #endif
 
+#define LOAD_EXT(name, type) \
+    sys->exts.name = (type) wglGetProcAddress("wgl" #name )
+
+    LOAD_EXT(GetExtensionsStringEXT, PFNWGLGETEXTENSIONSSTRINGEXTPROC);
+    if (!sys->exts.GetExtensionsStringEXT)
+        LOAD_EXT(GetExtensionsStringARB, PFNWGLGETEXTENSIONSSTRINGARBPROC);
+
+    wglMakeCurrent(sys->hGLDC, NULL);
+
+    gl->ext = VLC_GL_EXT_WGL;
     gl->makeCurrent = MakeCurrent;
     gl->releaseCurrent = ReleaseCurrent;
     gl->resize = NULL;
     gl->swap = Swap;
     gl->getProcAddress = OurGetProcAddress;
 
+    if (sys->exts.GetExtensionsStringEXT || sys->exts.GetExtensionsStringARB)
+        gl->wgl.getExtensionsString = GetExtensionsString;
+
     return VLC_SUCCESS;
 
 error:
@@ -251,3 +270,11 @@ static void ReleaseCurrent(vlc_gl_t *gl)
     vout_display_sys_t *sys = gl->sys;
     wglMakeCurrent (sys->hGLDC, NULL);
 }
+
+static const char *GetExtensionsString(vlc_gl_t *gl)
+{
+    vout_display_sys_t *sys = gl->sys;
+    return sys->exts.GetExtensionsStringEXT ?
+            sys->exts.GetExtensionsStringEXT() :
+            sys->exts.GetExtensionsStringARB(sys->hGLDC);
+}



More information about the vlc-commits mailing list