I'm reading Vulkan Tutorial and want to use Vulkan C++ binding instead. But error occured when I load vkCreateDebugUtilsMessengerEXT
and vkDestroyDebugUtilsMessengerEXT
.
Seems like instance.getProcAddr("extension_name")
won't really load a function into instance object, so I can't directly invoke, for example, destroyDebugUtilsMessengerEXT
by an object of vk::Instance
, because vkDestroyDebugUtilsMessengerEXT
is an unresolved symbol. The demo of Vulkan sdkcube.cpp
manually defines this function, so that the internal invocation of destroyDebugUtilsMessengerEXT
can find out a definition of vkDestroyDebugUtilsMessengerEXT
. But defining a function with same name of built-in function is definitely weird to me.
Also, I know the below is another way to do the same thing.
// This is the method in Vulkan Tutorial
// https://vulkan-tutorial.com/code/02_validation_layers.cpp
// Make a wrapper
void DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator) {
auto func = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
if (func != nullptr) {
func(instance, debugMessenger, pAllocator);
}
}
// And call it in cleanup()
DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr);
Could I have a neat way to load those functions without defining a function having same name of built-in or calling them by ugly C style code?