SDL_DuplicateSurface(3)
π NAME π
SDL_DuplicateSurface β bestie, it makes a brand new surface that's identical to the one you already have. it's giving clone, it's giving twin, it's giving copy-paste but make it β¨officialβ¨
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_surface.h>
SDL_Surface * SDL_DuplicateSurface(SDL_Surface *surface);
π¦ DESCRIPTION π¦
okay so here's the tea π« β if your original surface has alternate images, the new surface is gonna hold a reference to those same alternate images too. not a separate copy, a reference. iykyk.
and listen, the surface you get back? you gotta free it with SDL_DestroySurface(). like, actually. don't leave it hanging, that's not main character behavior, that's a memory leak π
π FUNCTION PARAMETERS π
surfaceβ the surface you wanna duplicate. the one. the only. the original β¨
β RETURN VALUE β
you get back a copy of the surface, slay π
β or NULL if it failed, which is giving flop energy π. when that happens, call SDL_GetError() for more info on what went wrong, fr fr.
π§ THREAD SAFETY π§
good news bestie: this one is thread-safe as long as you're calling it on different surfaces from different threads. so like, one thread per surface, and everyone's happy π no drama, no chaos, just vibes.
π AVAILABILITY π
this iconic function has been available since SDL 3.2.0 π
π SEE ALSO π
SDL_DestroySurface(3)β the one you will be calling after this. don't forget. i'm watching π
and that's the whole page, bestie π«Ά this gem lives in the SDL 3.4.18 era of the Simple Directmedia Layer manual, so go forth and duplicate responsibly β¨ππ¦π
π¦ 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