SDL_SetGPUTextureName(3)

πŸ’– SDL_SetGPUTextureName(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_SetGPUTextureName β€” the little function that slaps an arbitrary string constant onto a texture so it has a name. cute, right? πŸŽ€


✨ NAME ✨

SDL_SetGPUTextureName β€” sets an arbitrary string constant to label a texture. that's it. that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gpu.h>

void SDL_SetGPUTextureName(
    SDL_GPUDevice *device,
    SDL_GPUTexture *texture,
    const char *text);

look at that signature. three params, no return value, absolutely zero drama. πŸ¦‹


🫢 DESCRIPTION 🫢

okay so here's the tea, and it's important tea: you should use SDL_PROP_GPU_TEXTURE_CREATE_NAME_STRING with SDL_CreateGPUTexture instead of this function to avoid thread safety issues. 😭

like. this function works. but the property at creation time is the good path. this one is the "oops I forgot to name it and now I'm here" path. choose wisely, queen. πŸ‘‘


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • device β€” a GPU Context. your whole GPU situation. the main character. ✨
  • texture β€” a texture to attach the name to. this is the lil guy getting a nametag 🏷️
  • text β€” a UTF-8 string constant to mark as the name of the texture. UTF-8, bestie, don't come in here with your weird encodings. also note it's a string constant β€” a pointer to a literal-ish thing. πŸ“

πŸ’€ THREAD SAFETY πŸ’€

this function is not thread safe. you must make sure the texture is not simultaneously used by any other thread.

not me warning you twice but like. fr fr. do not let another thread touch that texture while this is running. no cap. that's a real crash-shaped consequence. πŸ™ˆ


🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on something older, no texture-naming for you, sorry babe. πŸ’œ


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! go forth and label your textures responsibly!! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ˜­πŸ”₯πŸ‘‘πŸŒˆβ­πŸ’€πŸ™ˆπŸ“πŸ§šπŸ’œ

this has been your girl delivering the Simple Directmedia Layer tea, straight from the SDL 3.4.18 era of the docs β€” mwah, stay iconic, and remember: name your textures at creation time. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from