glfwGetInstanceProcAddress function

GLFWvkproc glfwGetInstanceProcAddress(
  1. Pointer<Void> instance,
  2. String procname
)

! @brief Returns the address of the specified Vulkan instance function.

This function returns the address of the specified Vulkan core or extension function for the specified instance. If instance is set to NULL it can return any function exported from the Vulkan loader, including at least the following functions:

  • vkEnumerateInstanceExtensionProperties
  • vkEnumerateInstanceLayerProperties
  • vkCreateInstance
  • vkGetInstanceProcAddr

If Vulkan is not available on the machine, this function returns NULL and generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether Vulkan is at least minimally available.

This function is equivalent to calling vkGetInstanceProcAddr with a platform-specific query of the Vulkan loader as a fallback.

@paramin instance The Vulkan instance to query, or NULL to retrieve functions related to instance creation. @paramin procname The ASCII encoded name of the function. @return The address of the function, or NULL if an error(@ref error_handling) occurred.

@errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref GLFW_API_UNAVAILABLE.

@pointer_lifetime The returned function pointer is valid until the library is terminated.

@thread_safety This function may be called from any thread.

@sa @ref vulkan_proc

@since Added in version 3.2.

@ingroup vulkan

GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname)

Implementation

GLFWvkproc glfwGetInstanceProcAddress(Pointer<Void> instance, String procname) {
  final glfwGetInstanceProcAddressLookupFunction = libglfw.lookupFunction<
      GLFWvkproc Function(Pointer<Void> instance, Pointer<Utf8> procname),
      GLFWvkproc Function(Pointer<Void> instance,
          Pointer<Utf8> procname)>('glfwGetInstanceProcAddress');
  final procnamePointer = procname.toNativeUtf8();
  final result =
      glfwGetInstanceProcAddressLookupFunction(instance, procnamePointer);
  calloc.free(procnamePointer);
  return result;
}