SDL_LoadSurface(3)

πŸ“¦
version 3.4.18 Β· 5 versions
, in fedora 43, fedora 44

πŸ’– 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 πŸ‘‘


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