aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-14 15:21:36 -0500
committerDavid Robillard <d@drobilla.net>2023-01-14 16:18:27 -0500
commit64131038a4f0c3e3f5f5b95e083f0320a68de058 (patch)
tree1a94a4e1811495d746a16c038be0d1e0e345f622 /src
parente8dc1d219f4b461f29e11ad8fe0e463c6dfdb08b (diff)
downloadpugl-64131038a4f0c3e3f5f5b95e083f0320a68de058.tar.gz
pugl-64131038a4f0c3e3f5f5b95e083f0320a68de058.tar.bz2
pugl-64131038a4f0c3e3f5f5b95e083f0320a68de058.zip
Allow applications to specify the Vulkan library path
I don't know if vendoring the Vulkan library is appropriate, but regardless, this allows applications to set the name to whatever they want, or specify an absolute path, just in case the standard value baked into Pugl isn't the right one in some situation.
Diffstat (limited to 'src')
-rw-r--r--src/mac_vulkan.m6
-rw-r--r--src/win_vulkan.c8
-rw-r--r--src/x11_vulkan.c6
3 files changed, 13 insertions, 7 deletions
diff --git a/src/mac_vulkan.m b/src/mac_vulkan.m
index 2362db1..45c4839 100644
--- a/src/mac_vulkan.m
+++ b/src/mac_vulkan.m
@@ -107,7 +107,8 @@ struct PuglVulkanLoaderImpl {
};
PuglVulkanLoader*
-puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world))
+puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world),
+ const char* const libraryName)
{
PuglVulkanLoader* loader =
(PuglVulkanLoader*)calloc(1, sizeof(PuglVulkanLoader));
@@ -115,7 +116,8 @@ puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world))
return NULL;
}
- if (!(loader->libvulkan = dlopen("libvulkan.dylib", RTLD_LAZY))) {
+ const char* const filename = libraryName ? libraryName : "libvulkan.dylib";
+ if (!(loader->libvulkan = dlopen(filename, RTLD_LAZY))) {
free(loader);
return NULL;
}
diff --git a/src/win_vulkan.c b/src/win_vulkan.c
index ddd3fbe..4a4d005 100644
--- a/src/win_vulkan.c
+++ b/src/win_vulkan.c
@@ -21,7 +21,8 @@ struct PuglVulkanLoaderImpl {
};
PuglVulkanLoader*
-puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world))
+puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world),
+ const char* const libraryName)
{
PuglVulkanLoader* loader =
(PuglVulkanLoader*)calloc(1, sizeof(PuglVulkanLoader));
@@ -29,8 +30,9 @@ puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world))
return NULL;
}
- const DWORD flags = LOAD_LIBRARY_SEARCH_DEFAULT_DIRS;
- if (!(loader->libvulkan = LoadLibraryEx("vulkan-1.dll", NULL, flags))) {
+ const DWORD flags = LOAD_LIBRARY_SEARCH_DEFAULT_DIRS;
+ const char* const filename = libraryName ? libraryName : "vulkan-1.dll";
+ if (!(loader->libvulkan = LoadLibraryEx(filename, NULL, flags))) {
free(loader);
return NULL;
}
diff --git a/src/x11_vulkan.c b/src/x11_vulkan.c
index 54b1218..834ac37 100644
--- a/src/x11_vulkan.c
+++ b/src/x11_vulkan.c
@@ -26,9 +26,11 @@ struct PuglVulkanLoaderImpl {
};
PuglVulkanLoader*
-puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world))
+puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world),
+ const char* const libraryName)
{
- void* const libvulkan = dlopen("libvulkan.so", RTLD_LAZY);
+ const char* const filename = libraryName ? libraryName : "libvulkan.so";
+ void* const libvulkan = dlopen(filename, RTLD_LAZY);
if (!libvulkan) {
return NULL;
}