SDL_SetRenderClipRect(3)

✨ SDL_SetRenderClipRect ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_SetRenderClipRect(3) β€” the lil function that decides exactly where your renderer is allowed to draw. it's giving "scissors for pixels" πŸ’…


🌸 NAME 🌸

SDL_SetRenderClipRect β€” set the clip rectangle for rendering on the specified target. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_render.h>

bool SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);

πŸ’– DESCRIPTION πŸ’–

so here's the tea: every single render target has its own clip rectangle. no sharing, no borrowing, each one has its own. 🫢

this function sets the cliprect for the current render target. so whatever target you're on right now? that's the one getting the new clip. periodt.


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • renderer β€” the rendering context. your main character, the one doing the rendering.
  • rect β€” an SDL_Rect structure representing the clip area, and it's relative to the viewport. or pass NULL to disable clipping entirely β€” go wild, no scissors, draw everywhere πŸ¦‹

⭐ RETURN VALUE ⭐

returns true on success or false on failure. and if it fails? bestie, call SDL_GetError() for more information β€” it'll tell you what went wrong, i promise πŸ’œ


πŸ’€ THREAD SAFETY πŸ’€

this function should only be called on the main thread. no cap. don't try to be sneaky from a worker thread, it's not gonna slay.

🌈 AVAILABILITY 🌈

this function is available since SDL 3.2.0. so if you're on something older, sorry bestie, no clip rect for you 😭


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page fr fr. sourced straight from the Simple Directmedia Layer, SDL 3.4.18 edition β€” thanks for scrolling all the way down, you're literally the icon of reading documentation πŸ§šβœ¨πŸ’–

πŸ“¦ where this page comes from