SDL_BlitSurfaceTiled(3)

✨ SDL_BlitSurfaceTiled ✨

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, page SDL_BlitSurfaceTiled(3), and lemme tell you this one is lowkey iconic πŸ’…


πŸ’– NAME πŸ’–

SDL_BlitSurfaceTiled β€” do a tiled blit onto a destination surface, and yes it can be a whole different format, we don't gatekeep 🫢


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

bool SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the way this works is: the pixels sitting in srcrect get repeated as many times as needed to completely fill dstrect. that's it, that's the whole vibe. it's giving wallpaper. it's giving tiling window manager energy. it literally just keeps stamping that rectangle down until the target is full, periodt ✨


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • src β€” the SDL_Surface structure you're copying from. the source of truth, the main character πŸ‘‘
  • srcrect β€” the SDL_Rect structure representing the rectangle to be copied. pass NULL and it copies the entire surface instead, easy peasy πŸ“
  • dst β€” the SDL_Surface structure that is the blit target. this is where everything lands.
  • dstrect β€” the SDL_Rect structure representing the target rectangle in the destination surface. pass NULL and it fills the entire surface. no cap πŸ’œ

πŸ’€ RETURN VALUE πŸ’€

returns true on success or false on failure. and if it fails?? bestie, call SDL_GetError() for more information, she will tell you everything 😭


πŸ”₯ THREAD SAFETY πŸ”₯

only one thread should be using the src and dst surfaces at any given time. one. single. thread. don't be messy, it's not that kind of party πŸ™ˆ

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0 ⭐


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page bestie!! this has been the Simple Directmedia Layer manual, SDL 3.4.18 edition, SDL_BlitSurfaceTiled(3) β€” go tile something gorgeous, ily, bye πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from