GPU: device & frameSDL 3.2

SDL_ClaimWindowForGPUDevice

Connects a window to the GPU device by creating its swapchain, so you can draw into it.

Signature

bool SDL_ClaimWindowForGPUDevice(SDL_GPUDevice *device, SDL_Window *window);

How it works

The swapchain is the small set of images the window cycles through: one is on screen while you draw into another. Claiming the window builds it with vsync and standard (SDR) colours; SDL_SetGPUSwapchainParameters changes that afterwards.

Unlike raw Vulkan, SDL recreates the swapchain for you when the window is resized.

Parameters

deviceSDL_GPUDevice *

The device.

windowSDL_Window *

The window (no special flag needed).

Return value

true on success, false on failure.

Example

example.cpp
1if (!SDL_ClaimWindowForGPUDevice(device, window)) {
2    SDL_Log("ClaimWindow: %s", SDL_GetError());
3    return 1;
4}
Official SDL wiki