glfwCreateWindowSurface

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 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.

version(VK_VERSION_1_0)
extern (C) @nogc nothrow __gshared
VkResult
glfwCreateWindowSurface
(
VkInstance instance
,,
const(VkAllocationCallbacks)* allocator
,
VkSurfaceKHR* surface
)

Parameters

instance VkInstance

The Vulkan instance to create the surface in.

window GLFWwindow*

The window to create the surface for.

allocator const(VkAllocationCallbacks)*

The allocator to use, or null to use the default allocator.

surface VkSurfaceKHR*

Where to store the handle of the surface. This is set to VK_null_HANDLE if an error occurred.

Return Value

Type: VkResult

VK_SUCCESS if successful, or a Vulkan error code if an error 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 This function currently only supports the VK_MVK_macos_surface extension from MoltenVK.

@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

Meta

Since

Added in version 3.2.

Ingroup: vulkan