SDL_PointInRect(3)
π SDL_PointInRect(3) π
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today's main character is SDL_PointInRect β she's tiny, she's a header girlie, and she's here to answer the eternal question: is this point inside this rectangle or not π
β¨ NAME β¨
SDL_PointInRect β determine whether a point resides inside a rectangle π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_rect.h>
SDL_FORCE_INLINE bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r);
π¦ DESCRIPTION π¦
So here's the vibe check: a point counts as part of a rectangle if both p and r are not NULL, and p's x and y coordinates are >= to the rectangle's top left corner, and < the rectangle's x+w and y+h.
Not me doing the math out loud: a 1x1 rectangle considers point (0,0) as "inside" and (0,1) as not. πβ¨
ngl, this is a forced-inline function in a header, and not a public API function available in the SDL library β which is to say, the code is embedded in the calling program and the linker and dynamic loader will not be able to find this function inside SDL itself. it's giving "she's not on the roster, she lives in your code now" π
π FUNCTION PARAMETERS π
pβ the point to test. π«Άrβ the rectangle to test. π«Ά
β RETURN VALUE β
Returns true if p is contained by r, false otherwise. simple as that, no drama, no notes π
π§ THREAD SAFETY π§
It is safe to call this function from any thread. multithreaded slay, fr fr π
π AVAILABILITY π
This function is available since SDL 3.2.0. she's been iconic for a minute π«
and that's the whole page, bestie!! this little cutie comes to you courtesy of Simple Directmedia Layer, version SDL 3.4.18 β go forth and vibe check your rectangles ππβ¨
π¦ 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