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β theSDL_Surfacestructure to be copied from. this is the source of truth, the main character, the one we're taking pixels from πsrcrectβ theSDL_Rectstructure representing the rectangle to be copied, orNULLto copy the entire surface. so like, either you pick a lil window of pixels, or you take the whole thing, your call bestie β¨dstβ theSDL_Surfacestructure that is the blit target. this is where the pixels are going. the destination. the finale. the after-party πdstrectβ theSDL_Rectstructure representing the target rectangle in the destination surface, orNULLto fill the entire destination surface. again, specific rectangle orNULLfor the whole entire thing, we love options πscaleModeβ theSDL_ScaleModeto 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 sharingsrc, no sharingdst, 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
- 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