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 β€” the SDL_Surface structure that's getting clipped. she's the one being trimmed βœ‚οΈ
  • rect β€” the SDL_Rect structure that is the clipping rectangle. or, if you pass NULL, 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 🌈


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