summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2021-05-20 22:52:56 +1000
committerMatthew Waters <matthew@centricular.com>2021-05-21 14:12:11 +1000
commit512160a1c8ecfd55b44b5071026d3f261feeca4d (patch)
tree959f43289e4d0656128b842bf52849d75e2f6702
parentf8510ae3c8a585b8ef393e3788a511fa6a2dbe8f (diff)
downloadgstreamer-plugins-base-512160a1c8ecfd55b44b5071026d3f261feeca4d.tar.gz
gl/context/wgl: implement a better get_proc_address()
Look in opengl32.dll first, then wglGetProcAddress(), and only then possibly from any linked in libraries. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1165>
-rw-r--r--gst-libs/gst/gl/wgl/gstglcontext_wgl.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/gst-libs/gst/gl/wgl/gstglcontext_wgl.c b/gst-libs/gst/gl/wgl/gstglcontext_wgl.c
index d75dc32fd..b24f46c93 100644
--- a/gst-libs/gst/gl/wgl/gstglcontext_wgl.c
+++ b/gst-libs/gst/gl/wgl/gstglcontext_wgl.c
@@ -24,6 +24,7 @@
#endif
#include <gst/gst.h>
+#include <gmodule.h>
#include <gst/gl/gl.h>
#include <gst/gl/gstglfuncs.h>
@@ -468,14 +469,43 @@ gst_gl_context_wgl_check_feature (GstGLContext * context, const gchar * feature)
return gst_gl_check_extension (feature, context_wgl->priv->wgl_exts);
}
+static GOnce module_opengl_dll_gonce = G_ONCE_INIT;
+static GModule *module_opengl_dll;
+
+static gpointer
+load_opengl_dll_module (gpointer user_data)
+{
+#ifdef GST_GL_LIBGL_MODULE_NAME
+ module_opengl_dll =
+ g_module_open (GST_GL_LIBGL_MODULE_NAME, G_MODULE_BIND_LAZY);
+#else
+ if (g_strcmp0 (G_MODULE_SUFFIX, "dll") == 0)
+ module_opengl_dll = g_module_open ("opengl32.dll", G_MODULE_BIND_LAZY);
+
+ /* This automatically handles the suffix and even .la files */
+ if (!module_opengl_dll)
+ module_opengl_dll = g_module_open ("opengl32", G_MODULE_BIND_LAZY);
+#endif
+
+ return NULL;
+}
+
gpointer
gst_gl_context_wgl_get_proc_address (GstGLAPI gl_api, const gchar * name)
{
gpointer result;
- if (!(result = gst_gl_context_default_get_proc_address (gl_api, name))) {
- result = wglGetProcAddress ((LPCSTR) name);
+ if (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3)) {
+ g_once (&module_opengl_dll_gonce, load_opengl_dll_module, NULL);
+ if (module_opengl_dll)
+ g_module_symbol (module_opengl_dll, name, &result);
+
+ if (!result) {
+ result = wglGetProcAddress ((LPCSTR) name);
+ }
}
+ if (!result)
+ result = gst_gl_context_default_get_proc_address (gl_api, name);
return result;
}