SDL_SETGPUSWAPCHAINPARAMETERS(3)

πŸ’… SDL_SetGPUSwapchainParameters(3) πŸ’…

okay bestie so this is a page from the SDL3 FUNCTIONS collection, and it's about SDL_SetGPUSwapchainParameters β€” yes it's a mouthful, yes it's iconic, let's get into it 🫢


✨ NAME ✨

SDL_SetGPUSwapchainParameters β€” changes the swapchain parameters for the given claimed window. that's it, that's the whole job, no cap πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_gpu.h>

bool SDL_SetGPUSwapchainParameters(
    SDL_GPUDevice *device,
    SDL_Window *window,
    SDL_GPUSwapchainComposition swapchain_composition,
    SDL_GPUPresentMode present_mode);

look at that signature, so clean, so put-together 🌸


✨ DESCRIPTION ✨

so like. this function will fail if the present mode or the swapchain composition you're asking for aren't supported by the device 😭 like it's not gonna be nice about it, it's just gonna say no.

the way you avoid that heartbreak is: check if your parameters are even supported first, using SDL_WindowSupportsGPUPresentMode / SDL_WindowSupportsGPUSwapchainComposition, before you call this function. vibe check first, ask questions later, fr fr πŸ’–

and here's the one guaranteed slay: SDL_GPU_PRESENTMODE_VSYNC with SDL_GPU_SWAPCHAINCOMPOSITION_SDR is always supported. always. periodt πŸ‘‘


✨ FUNCTION PARAMETERS ✨

  • device β€” a GPU context. your whole GPU situation.
  • window β€” an SDL_Window that has been claimed. claimed!! key word, don't skip it πŸ’…
  • swapchain_composition β€” the desired composition of the swapchain. what you want it to be.
  • present_mode β€” the desired present mode for the swapchain. again, desired, we're manifesting here πŸ¦‹

✨ RETURN VALUE ✨

returns true if successful, false on error πŸ”₯ and if you get a false, go call SDL_GetError() for more information β€” she will tell you what went wrong, so listen to her.


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0 ⭐ so if you're on something older, that's a you problem, upgrade bestie.


✨ SEE ALSO ✨

go read those two first, they're the pre-flight check and they will save you so much grief πŸ™ˆ


and that's the page!! brought to you by Simple Directmedia Layer, SDL 3.4.18, and this very SDL_SetGPUSwapchainParameters(3) moment πŸ’œ mwah, go claim ur window and set those params, you got this 🧚✨

πŸ“¦ where this page comes from