SDL_CreateGPUDevice(3)

πŸ’– SDL_CreateGPUDevice πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today we're building a whole entire GPU context. yes, really. sit down, hydrate, let's go ✨


🌸 NAME 🌸

SDL_CreateGPUDevice β€” Creates a GPU context.

like, it makes the GPU context. that's the whole job. main character energy fr πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_gpu.h>

SDL_GPUDevice * SDL_CreateGPUDevice(
    SDL_GPUShaderFormat format_flags,
    bool debug_mode,
    const char *name);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the GPU driver name you pass in can be one of these, no cap:

  • "vulkan": [Vulkan](CategoryGPU#vulkan) πŸ”₯
  • "direct3d12": [D3D12](CategoryGPU#d3d12) πŸ’œ
  • "metal": [Metal](CategoryGPU#metal) πŸŽ€
  • NULL: just let SDL pick the optimal driver, bestie. she knows what she's doing 🫢

✨ FUNCTION PARAMETERS ✨

  • format_flags β€” a bitflag indicating which shader formats the app is able to provide. it's giving "here's what I brought to the party" πŸ’ƒ
  • debug_mode β€” enable debug mode properties and validations. turn this on when you want the extra checks, lowkey essential while you're still figuring things out πŸ™ˆ
  • name β€” the preferred GPU driver, or NULL to let SDL pick the optimal driver. queen behavior, delegating πŸ’…

🌈 RETURN VALUE 🌈

Returns a GPU context on success or NULL on failure β€” and if it fails, call SDL_GetError() for more information, because she will tell you exactly what went wrong 😭


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. iconic since day one, periodt πŸ‘‘


πŸ’œ SEE ALSO πŸ’œ


ok so quick vibe check: if you made a device, you gotta SDL_DestroyGPUDevice it later. don't leave her hanging. 🫢

that's the whole page bestie, mwah πŸ’– this one's from Simple Directmedia Layer, SDL 3.4.18 era β€” go forth and create your GPU device, you absolute legend πŸŒΈβœ¨πŸŽ€

πŸ“¦ where this page comes from