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