SDL_StretchSurface(3)

πŸ’– SDL_StretchSurface πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, page SDL_StretchSurface(3). this one is a lil glow-up of a function and i'm obsessed. sit down, hydrate, let's go 🫢


✨ NAME ✨

SDL_StretchSurface β€” Perform a stretched pixel copy from one surface to another.

yes. that's it. that's the whole vibe. pixels, but stretched πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_surface.h>

bool SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);

not me writing out the whole signature like it's a love letter, but here we are πŸ’Œ


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

okay so here's the cast of characters, and every single one of them matters, no skips:

  • src β€” the SDL_Surface structure to be copied from. this is the source of truth, the main character, the one we're taking pixels from πŸ‘‘
  • srcrect β€” the SDL_Rect structure representing the rectangle to be copied, or NULL to copy the entire surface. so like, either you pick a lil window of pixels, or you take the whole thing, your call bestie ✨
  • dst β€” the SDL_Surface structure that is the blit target. this is where the pixels are going. the destination. the finale. the after-party 🌈
  • dstrect β€” the SDL_Rect structure representing the target rectangle in the destination surface, or NULL to fill the entire destination surface. again, specific rectangle or NULL for the whole entire thing, we love options πŸ’œ
  • scaleMode β€” the SDL_ScaleMode to be used. this is the lil setting that decides how the stretching behaves, so don't sleep on it πŸ¦‹

⭐ RETURN VALUE ⭐

Returns true on success or false on failure; call SDL_GetError() for more information.

so like, if it comes back false, do not just sit there spiraling 😭 β€” call SDL_GetError() and it will tell you what went wrong. communication is key, fr fr.


🧚 THREAD SAFETY 🧚

Only one thread should be using the src and dst surfaces at any given time.

bestie. hear me. ONE. THREAD. AT. A. TIME. no sharing src, no sharing dst, no "but it worked that one time." that's giving chaos and we don't do chaos here πŸ™ˆ

πŸ’« AVAILABILITY πŸ’«

This function is available since SDL 3.4.0.

so if you're on something older than SDL 3.4.0, this icon is simply not in your era yet, sorry babe πŸ’€


πŸ‘€ SEE ALSO πŸ‘€

go read that one too, iykyk πŸ”₯


and that's the whole page, no notes, ate and left no crumbs πŸ’…

Simple Directmedia Layer Β· version SDL 3.4.18 β€” mwah, sending you and your stretched pixels so much love, go make something iconic πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from