SDL_PointInRectFloat(3)

πŸ’– SDL_PointInRectFloat(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the group chat β€” today we're learning SDL_PointInRectFloat, and honestly? it's giving "tiny function, big main character energy." πŸŽ€


✨ NAME ✨

SDL_PointInRectFloat β€” determine whether a point resides inside a floating point rectangle. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_rect.h>

SDL_FORCE_INLINE bool SDL_PointInRectFloat(const SDL_FPoint *p, const SDL_FRect *r);

πŸ’… DESCRIPTION πŸ’…

so here's the tea β˜• β€” a point counts as part of a rectangle if both p and r are not NULL, and p's x and y coordinates are >= the rectangle's top left corner, and <= the rectangle's x+w and y+h.

basically the rectangle is inclusive at the edges, no gatekeeping πŸ’–. so a 1x1 rectangle considers point (0,0) and (0,1) as "inside" and (0,2) as not. not me double-checking the math three times bestie, it's fr fr correct.

🫢 heads up: 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 a header girlie, she lives in your code, not in the library. periodt. πŸ‘‘

πŸŽ€ 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 cap. ✨


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. go off, multithreaded queen πŸ’œ


πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0. iconic since day one, lowkey. 🌸


and that's the whole vibe check, bestie β€” this page came to you straight from Simple Directmedia Layer, rockin' SDL 3.4.18, in the SDL_PointInRectFloat(3) era. stay floaty, stay inside the rect πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from