SDL_SetSurfaceClipRect(3)
π NAME π
ok so like, SDL_SetSurfaceClipRect β it sets the clipping rectangle for a surface. that's the whole job bestie, and she does it flawlessly β¨
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_surface.h>
bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect);
π DESCRIPTION π
okay so picture this: your surface is the destination of a blit. when that happens, the only area that actually gets drawn into is the area inside the clip rectangle. everything outside it? not invited. blocked. gatekept. π
and here's the little bonus lore β blits are automatically clipped to the edges of the source and destination surfaces anyway. so even without you doing anything, the universe is already handling the surface boundaries for you. iconic behavior fr fr π
π¦ FUNCTION PARAMETERS π¦
surfaceβ theSDL_Surfacestructure that's getting clipped. she's the one being trimmed βοΈrectβ theSDL_Rectstructure that is the clipping rectangle. or, if you passNULL, clipping gets disabled entirely. no rectangle, no rules π«Ά
β¨ RETURN VALUE β¨
returns true if the rectangle actually intersects the surface. otherwise it returns false β and heads up, in that case blits will be completely clipped. like, nothing gets through. zero. nada. π
π§ THREAD SAFETY π§
good news bestie, this one's chill: you can call it on different threads with different surfaces. no drama, no fighting π
β AVAILABILITY β
this function has been around since SDL 3.2.0. she's been serving for a minute π
π SEE ALSO π
SDL_GetSurfaceClipRect(3)β the other half of the duo, go read her too π
and that's the whole page babes!! this lil masterpiece lives in the Simple Directmedia Layer manual, straight outta SDL 3.4.18 β tysm for reading, ily, go clip something gorgeous πβ¨πΈπ¦
π¦ 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