SDL_BlitSurface(3)
π SDL_BlitSurface β bestie edition π
okay so this is a page from the SDL3 FUNCTIONS manual (yes the whole fam, we're in the SDL3 section) and it's about SDL_BlitSurface. it does a fast blit from the source surface to the destination surface, with clipping. no cap. π¦
β¨ NAME β¨
SDL_BlitSurface β Performs a fast blit from the source surface to the destination surface with clipping.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_surface.h>
bool SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
π DESCRIPTION π
so here's the vibe. if srcrect or dstrect are NULL, the entire surface (src or dst) gets copied, while making sure everything stays clipped to dst->clip_rect. very demure, very mindful. π
π¨ not me calling a blit on a locked surface β bestie, do NOT do that. the blit function should not be called on a locked surface. periodt.
the blit semantics for surfaces with and without blending and colorkey are defined as follows, and this is the part you're gonna wanna screenshot:
π RGBA->RGB
- Source surface blend mode set to
SDL_BLENDMODE_BLEND:- alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEYignored.
- Source surface blend mode set to
SDL_BLENDMODE_NONE:- copy RGB.
- if
SDL_SRCCOLORKEYset, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
π RGB->RGBA
- Source surface blend mode set to
SDL_BLENDMODE_BLEND:- alpha-blend (using the source per-surface alpha)
- Source surface blend mode set to
SDL_BLENDMODE_NONE:- copy RGB, set destination alpha to source per-surface alpha value.
- both:
- if
SDL_SRCCOLORKEYset, only copy the pixels that do not match the source color key.
- if
π RGBA->RGBA
- Source surface blend mode set to
SDL_BLENDMODE_BLEND:- alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEYignored.
- Source surface blend mode set to
SDL_BLENDMODE_NONE:- copy all of RGBA to the destination.
- if
SDL_SRCCOLORKEYset, only copy the pixels that do not match the RGB values of the source color key, ignoring alpha in the comparison.
π RGB->RGB
- Source surface blend mode set to
SDL_BLENDMODE_BLEND:- alpha-blend (using the source per-surface alpha)
- Source surface blend mode set to
SDL_BLENDMODE_NONE:- copy RGB.
- both:
- if
SDL_SRCCOLORKEYset, only copy the pixels that do not match the source color key.
- if
π FUNCTION PARAMETERS π
srcβ theSDL_Surfacestructure to be copied from. the source, the origin story, the main character. πsrcrectβ theSDL_Rectstructure representing the rectangle to be copied, orNULLto copy the entire surface.dstβ theSDL_Surfacestructure that is the blit target. it's getting the glow-up.dstrectβ theSDL_Rectstructure representing the x and y position in the destination surface, orNULLfor(0,0). the width and height are ignored, and are copied fromsrcrect. so if you want a specific width and height, you should useSDL_BlitSurfaceScaled(). iykyk. π«Ά
π«Ά RETURN VALUE π«Ά
Returns true on success or false on failure; call SDL_GetError() for more information. slay or flop, it's giving binary. π
π§΅ THREAD SAFETY π§΅
Only one thread should be using the src and dst surfaces at any given time. no sharing, no passing them around the group chat while someone else is typing. π
π AVAILABILITY π
This function is available since SDL 3.2.0.
π SEE ALSO π
and that's the whole thing bestie, you ate π β¨
β brought to you by the Simple Directmedia Layer girlies, running the SDL 3.4.18 era, and the page is literally just called SDL_BlitSurface(3). bye ily π¦πΈπ
π¦ 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