SDL_LoadSurface(3)
π SDL_LoadSurface β the manual page, but make it cute π
okay bestie, so you're in the SDL3 FUNCTIONS section of the manual and you found SDL_LoadSurface(3) and honestly? iconic. let's get into it β¨
πΈ NAME πΈ
SDL_LoadSurface β loads a BMP or PNG image from a file. that's it, that's the girl π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_surface.h>
SDL_Surface * SDL_LoadSurface(const char *file);
π DESCRIPTION π
okay so this function hands you a shiny new surface, and the way that you HAVE to free it after β with SDL_DestroySurface() β is not optional, it's a lifestyle.
β οΈ no cap: if you don't free it with SDL_DestroySurface(), you get a memory leak. your RAM will simply be sitting there, unwell. π
π FUNCTION PARAMETERS π
fileβ the file to load. that's the one, the only, the path you're handing over π
β¨ RETURN VALUE β¨
it returns a pointer to a brand new SDL_Surface structure β slay β or NULL if it failed, which is giving π.
if you get NULL? call SDL_GetError() for more info, she'll tell you what went wrong π«Ά
π§ THREAD SAFETY π§
it is safe to call this function from any thread. go off, multi-threaded queen π
π AVAILABILITY π
this function has been available since SDL 3.4.0 β so if you're on anything older, bestie, you're out of luck π
π SEE ALSO π
SDL_DestroySurface(3)β the one you MUST call, remember? periodt.SDL_LoadSurface_IO(3)
and that's the whole page, you ate that π Simple Directmedia Layer is the source, this is SDL 3.4.18, and yes the footer also says SDL_LoadSurface(3) because we're keeping it consistent, mwah π
π¦ 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