pub unsafe extern "C" fn glfwCreateWindowSurface(
instance: *mut VkInstance_T,
window: *mut GLFWwindow,
allocator: *const VkAllocationCallbacks,
surface: *mut *mut VkSurfaceKHR_T,
) -> i32Expand description
@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.
@param[in] instance The Vulkan instance to create the surface in.
@param[in] window The window to create the surface for.
@param[in] allocator The allocator to use, or NULL to use the default
allocator.
@param[out] 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.
@remark @x11 By default GLFW prefers the VK_KHR_xcb_surface extension,
with the VK_KHR_xlib_surface extension as a fallback. You can make
VK_KHR_xlib_surface the preferred extension by setting the
GLFW_X11_XCB_VULKAN_SURFACE(@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
hint. The name of the selected extension, if any, is included in the array
returned by @ref glfwGetRequiredInstanceExtensions.
@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