vlc | branch: master | Alexandre Janniaux <[email protected]> | Thu Jan 28 
09:08:23 2021 +0100| [c7caeda551f1b1949a99c49b8f6a303a113711e4] | committer: 
Alexandre Janniaux

wgl: forward all symbols through GetProcAddress

Mimic the EGL_KHR_get_all_proc_address extension and forward every
OpenGL client function through the get_proc_address callback.

Effectively fix the glwin32 display which wasn't working anymore since
the split into libvlc_opengl da1853b2c2db853f337dc95dbf0164922d050a1b.

Refs #25234

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

 modules/video_output/Makefile.am |  2 +-
 modules/video_output/win32/wgl.c | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index 8f56e4f734..b77fefda36 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -160,7 +160,7 @@ libwgl_plugin_la_SOURCES = video_output/win32/wgl.c
 libglwin32_plugin_la_LIBADD = libchroma_copy.la -lopengl32 -lgdi32 $(LIBCOM) 
-luuid libvlc_opengl.la
 libwgl_plugin_la_LIBADD = -lopengl32 -lgdi32 libvlc_opengl.la
 
-libglwin32_plugin_la_CFLAGS = $(AM_CFLAGS) $(OPENGL_COMMONCFLAGS) 
-DHAVE_GL_CORE_SYMBOLS
+libglwin32_plugin_la_CFLAGS = $(AM_CFLAGS) $(OPENGL_COMMONCFLAGS)
 libwgl_plugin_la_CFLAGS = $(AM_CFLAGS) $(OPENGL_COMMONCFLAGS)
 
 libglwin32_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)'
diff --git a/modules/video_output/win32/wgl.c b/modules/video_output/win32/wgl.c
index ec02c2dc6e..0622e3e590 100644
--- a/modules/video_output/win32/wgl.c
+++ b/modules/video_output/win32/wgl.c
@@ -62,6 +62,7 @@ struct vout_display_sys_t
     HWND                  hvideownd;
     HDC                   hGLDC;
     HGLRC                 hGLRC;
+    HMODULE               hOpengl;
     vlc_gl_t              *gl;
     HDC                   affinityHDC; // DC for the selected GPU
 
@@ -173,6 +174,7 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned 
height)
 
     sys->hvideownd = wnd->handle.hwnd;
     sys->hGLDC = GetDC(sys->hvideownd);
+    sys->hOpengl = LoadLibraryA("opengl32.dll");
     if (sys->hGLDC == NULL)
     {
         msg_Err(gl, "Could not get the device context");
@@ -256,6 +258,8 @@ static void Close(vlc_gl_t *gl)
         wglDeleteContext(sys->hGLRC);
     if (sys->hGLDC)
         ReleaseDC(sys->hvideownd, sys->hGLDC);
+    if (sys->hOpengl)
+        FreeLibrary(sys->hOpengl);
 
     DestroyGPUAffinityDC(gl);
 
@@ -270,8 +274,16 @@ static void Swap(vlc_gl_t *gl)
 
 static void *OurGetProcAddress(vlc_gl_t *gl, const char *name)
 {
-    VLC_UNUSED(gl);
-    return wglGetProcAddress(name);
+    vout_display_sys_t *sys = gl->sys;
+
+    /* See https://www.khronos.org/opengl/wiki/Load_OpenGL_Functions */
+    void *f= (void *)wglGetProcAddress(name);
+    if(f == 0 || (f == (void*)0x1) || (f == (void*)0x2) ||
+      (f == (void*)0x3) || (f == (void*)-1) )
+    {
+        f = (void *)GetProcAddress(sys->hOpengl, name);
+    }
+    return f;
 }
 
 static int MakeCurrent(vlc_gl_t *gl)

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to