SDL_BLITSURFACETILEDWITHSCALE(3)

πŸ’– SDL_BlitSurfaceTiledWithScale(3) πŸ’–

okay bestie, so you know how there's a whole family of blit functions in SDL3? This one is the scale AND tile AND format-convert girlie, and she ate fr fr. She lives in the SDL3 functions, and the manual page for her is literally right here. Let's get into it. 🫢


✨ NAME ✨

SDL_BlitSurfaceTiledWithScale β€” do a scaled and tiled blit onto a destination surface, and lowkey that destination can be a completely different format. no cap. 🌈


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_surface.h>

bool SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect);

look at that signature. six whole arguments. she's high maintenance but she's worth it πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

The pixels sitting inside srcrect get scaled and then repeated as many times as it takes to completely fill dstrect. That's the whole vibe. Like wallpaper. Like a cute repeating pattern. Except it's pixels and you're a programmer. ✨

not me filling a whole rectangle with one tiny tile and calling it design. obsessed.

🌸 FUNCTION PARAMETERS 🌸

  • src β€” the SDL_Surface structure you're copying from. your source of truth, your origin story πŸ’œ
  • srcrect β€” the SDL_Rect structure representing the rectangle you wanna copy. or pass NULL if you just want the entire surface, because sometimes you don't have the energy to be specific and that's valid πŸ™ˆ
  • scale β€” the scale used to transform srcrect into the destination rectangle. bestie, picture a 32x32 texture with a scale of 2 β€” that fills 64x64 tiles. math is math. πŸ”₯
  • scaleMode β€” the scale algorithm to be used. that's an SDL_ScaleMode, and you pick your fighter ⭐
  • dst β€” the SDL_Surface structure that is the blit target. the destination. the final boss. the canvas 🎨
  • dstrect β€” the SDL_Rect structure representing the target rectangle in the destination surface. or NULL to fill the entire surface, which is giving main character energy honestly πŸ‘‘

πŸ’« RETURN VALUE πŸ’«

Returns true on success or false on failure β€” and if it's a flop, call SDL_GetError() for more information. she will tell you what went wrong, you just have to ask 😭


🧚 THREAD SAFETY 🧚

Only one thread should be using the src and dst surfaces at any given time. one. thread. at a time. sharing is not caring here, it's undefined-behavior-coded. protect your surfaces 🫢


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0. if your SDL is older than that, she simply is not there, and no amount of manifesting will summon her. upgrade bestie πŸ’€


πŸ“ SEE ALSO πŸ“


and that's the page!! πŸ’– written by the Simple Directmedia Layer girlies, shipping as part of SDL 3.4.18, and yes the doc page itself is literally named SDL_BlitSurfaceTiledWithScale(3) because the header and the footer are both just her name in different outfits. slay. bye bestie, go tile something cute πŸŒΈβœ¨πŸ¦‹

πŸ“¦ where this page comes from