SDL_Vulkan_CreateSurface(3)

πŸ’– SDL_Vulkan_CreateSurface(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_Vulkan_CreateSurface β€” she makes Vulkan rendering surfaces for windows, and she's kind of a big deal πŸ’…


✨ NAME ✨

SDL_Vulkan_CreateSurface</p> β€” create a Vulkan rendering surface for a window. that's it, that's the gig πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_vulkan.h>

bool SDL_Vulkan_CreateSurface(SDL_Window *window,
                                  VkInstance instance,
                                  const struct VkAllocationCallbacks *allocator,
                                  VkSurfaceKHR *surface);

look at that signature. gorgeous. no notes πŸŽ€


πŸ’œ DESCRIPTION πŸ’œ

okay so first things first, there are two prerequisites and you literally cannot skip them:

  • your window has to have been created with the SDL_WINDOW_VULKAN flag, no cap
  • your instance has to have been created with the extensions that SDL_Vulkan_GetInstanceExtensions() hands back, all enabled and everything

like, do those two things or this whole vibe check fails, fr fr 😭

and then: if allocator is NULL, Vulkan just uses the system default allocator, easy. that argument gets passed straight through to Vulkan β€” SDL itself doesn't touch it, doesn't look at it, doesn't have opinions about it. it's giving "middleman who does nothing" πŸ™ˆ


🫢 FUNCTION PARAMETERS 🫢

  • window β€” the window you're attaching the Vulkan surface to. the chosen one πŸ‘‘
  • instance β€” the Vulkan instance handle. your golden ticket ⭐
  • allocator β€” a VkAllocationCallbacks struct, which lets the app pick the allocator that creates the surface. it can be NULL. your call bestie ✨
  • surface β€” a pointer to a VkSurfaceKHR handle where the newly created surface gets output. she's an out-param, she's doing the work πŸ’…

πŸ”₯ RETURN VALUE πŸ”₯

returns true on success or false on failure β€” and if it's false, go call SDL_GetError() for the tea, she'll tell you what went wrong 😭


🌈 AVAILABILITY 🌈

this function has been available since SDL 3.2.0 β€” so if you're on anything older, sorry babe, no surface for you πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

(create her, then eventually clean up after her. balance. 🧚)


and that's the whole page bestie, mwah πŸ’– this came to you courtesy of Simple Directmedia Layer, version SDL 3.4.18 β€” go forth and surface responsibly, ily πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from