glfwCreateWindowSurface function

Pointer<Void> glfwCreateWindowSurface(
  1. Pointer<Void> instance,
  2. Pointer<GLFWwindow> window,
  3. Pointer<Void> allocator,
  4. Pointer<Void> surface,
)

! @brief Creates a Vulkan surface for the specified window.

This function creates a Vulkan surface for the specified window.

If the Vulkan loader or at least one minimally functional ICD were not found, this function returns VK_ERROR_INITIALIZATION_FAILED and generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported to check whether Vulkan is at least minimally available.

If the required window surface creation instance extensions are not available or if the specified instance was not created with these extensions enabled, this function returns VK_ERROR_EXTENSION_NOT_PRESENT and generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwGetRequiredInstanceExtensions to check what instance extensions are required.

The window surface cannot be shared with another API so the window must have been created with the client api hint(@ref GLFW_CLIENT_API_attrib) set to GLFW_NO_API otherwise it generates a @ref GLFW_INVALID_VALUE error and returns VK_ERROR_NATIVE_WINDOW_IN_USE_KHR.

The window surface must be destroyed before the specified Vulkan instance. It is the responsibility of the caller to destroy the window surface. GLFW does not destroy it for you. Call vkDestroySurfaceKHR to destroy the surface.

@paramin instance The Vulkan instance to create the surface in. @paramin window The window to create the surface for. @paramin allocator The allocator to use, or NULL to use the default allocator. @paramout surface Where to store the handle of the surface. This is set to VK_NULL_HANDLE if an error occurred. @return VK_SUCCESS if successful, or a Vulkan error code if an error(@ref error_handling) occurred.

@errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE

@remark If an error occurs before the creation call is made, GLFW returns the Vulkan error code most appropriate for the error. Appropriate use of @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should eliminate almost all occurrences of these errors.

@remark @macos GLFW prefers the VK_EXT_metal_surface extension, with the VK_MVK_macos_surface extension as a fallback. The name of the selected extension, if any, is included in the array returned by @ref glfwGetRequiredInstanceExtensions.

@remark @macos This function creates and sets a CAMetalLayer instance for the window content view, which is required for MoltenVK to function.

@thread_safety This function may be called from any thread. For synchronization details of Vulkan objects, see the Vulkan specification.

@sa @ref vulkan_surface @sa @ref glfwGetRequiredInstanceExtensions

@since Added in version 3.2.

@ingroup vulkan

GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface)

Implementation

Pointer<Void> glfwCreateWindowSurface(
    Pointer<Void> instance,
    Pointer<GLFWwindow> window,
    Pointer<Void> allocator,
    Pointer<Void> surface) {
  final glfwCreateWindowSurfaceLookupFunction = libglfw.lookupFunction<
      Pointer<Void> Function(Pointer<Void> instance, Pointer<GLFWwindow> window,
          Pointer<Void> allocator, Pointer<Void> surface),
      Pointer<Void> Function(
          Pointer<Void> instance,
          Pointer<GLFWwindow> window,
          Pointer<Void> allocator,
          Pointer<Void> surface)>('glfwCreateWindowSurface');
  return glfwCreateWindowSurfaceLookupFunction(
      instance, window, allocator, surface);
}