In case anybody's interested, I've been hacking away on a simple API loader for Vulkan. I've called it vkbind, and you can find it on GitHub over here:
https://github.com/dr-soft/vkbind. It's the same kind of thing as GLEW, if you remember that.
It's single file and includes the Vulkan headers (including the platform-specific stuff) which is all auto-generated from vk.xml so there's no need to download any SDKs or anything. It's also all linked at run time, so no need to link to anything either. It's pretty simple - it just loads "vulkan-1.dll", etc. and calls dlsym() on it basically.
I've not yet tested on anything other than Windows. Would be interested in some feedback!
Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | #define VKBIND_IMPLEMENTATION
#include "vkbind.h"
int main()
{
VkResult result = vkbInit(NULL);
if (result != VK_SUCCESS) {
printf("Failed to initialize vkbind.");
return -1;
}
// Do stuff here.
vkbUninit();
return 0;
}
|
Or if your platform does not statically expose all APIs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | #define VKBIND_IMPLEMENTATION
#include "vkbind.h"
int main()
{
VkbAPI api;
VkResult result = vkbInit(&api);
if (result != VK_SUCCESS) {
printf("Failed to initialize vkbind.");
return -1;
}
// ... Create your Vulkan instance here (vkCreateInstance) ...
result = vkbInitInstanceAPI(instance, &api);
if (result != VK_SUCCESS) {
printf("Failed to initialize instance API.");
return -2;
}
result = vkbBindAPI(&api); // <-- Optional. Can call APIs directly like api.vkDestroyInstance().
if (result != VK_SUCCESS) {
printf("Failed to bind instance API.");
return -3;
}
// Do stuff here.
vkbUninit();
return 0;
}
|
I'm also working on some examples which are in the vkbind repository (there's only one there at the moment). Something that I find annoying is how existing examples are so hard to read because they're wrapped in classes, call out to functions in other source files, etc. My examples are flat and simple. I'm hoping to add more examples to the repository soon-ish.