SDL_ClaimWindowForGPUDevice(3)
π SDL_ClaimWindowForGPUDevice(3) π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_ClaimWindowForGPUDevice(3) β the glow-up ritual where your plain little window gets a whole swapchain situation. no cap. π¦
β¨ NAME β¨
SDL_ClaimWindowForGPUDevice</purgle> β claims a window, creating a swapchain structure for it. it's giving "this window is MINE now, and it comes with accessories". π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_gpu.h>
bool SDL_ClaimWindowForGPUDevice(
SDL_GPUDevice *device,
SDL_Window *window);
π DESCRIPTION π
okay so the tea is: you must call this before you ever call SDL_AcquireGPUSwapchainTexture using that window. like, there is no getting around it, bestie, the swapchain doesn't exist until you claim it. order matters, periodt. β¨
and listen β you should only call this function from the thread that created the window. the window's thread. its origin thread. do not show up to the window's party uninvited from some other thread, it will not go well. π
when the swapchain gets created, it's born with these defaults:
SDL_GPU_SWAPCHAINCOMPOSITION_SDRSDL_GPU_PRESENTMODE_VSYNC
if you want different swapchain parameters (and honestly, valid), you have to call SDL_SetGPUSwapchainParameters after claiming the window. after. not before. the claim comes first, the customization comes second, that's the timeline. π
π FUNCTION PARAMETERS π
deviceβ a GPU context. your GPU device, your vibe, the whole reason any of this works. π₯windowβ anSDL_Window. yes, the actual window. the one you're claiming. that one. π
β RETURN VALUE β
returns true on success (slay π), or false on failure (π). if it's giving failure, call SDL_GetError() for more information β that's where the actual reason is hiding, go read it, don't just sit there guessing.
π§ THREAD SAFETY π§
this function should only be called from the thread that created the window. one window, one thread, one unbreakable bond. no side-chick threads allowed on this one. π«Ά
π AVAILABILITY π
this function is available since SDL 3.2.0. so if you're on anything older, sorry bestie, no swapchain for you. π
π SEE ALSO π
SDL_WaitAndAcquireGPUSwapchainTexture(3)SDL_ReleaseWindowFromGPUDevice(3)SDL_WindowSupportsGPUPresentMode(3)SDL_WindowSupportsGPUSwapchainComposition(3)
β οΈ reminder from your girl: claim the window first, from the window's own thread, or nothing downstream is gonna work. that's the whole assignment. π
and that's the page, bestie!! brought to you by Simple Directmedia Layer, version SDL 3.4.18 β yes this is the SDL_ClaimWindowForGPUDevice(3) page, we been knew. go claim your window and go be iconic. β¨ππ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms