SDL_GetRectIntersection(3)

✨ SDL_GetRectIntersection ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, page SDL_GetRectIntersection(3) πŸ’–

🌸 NAME 🌸

SDL_GetRectIntersection β€” Calculate the intersection of two rectangles. that's it, that's the whole job, and she does it flawlessly πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_rect.h>

bool SDL_GetRectIntersection(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie: you hand her two rectangles and she figures out where they overlap and drops that overlap into result. iconic behavior honestly.

BUT β€” and this is the important part β€” if result is NULL, then this function will return false. no result to fill, no vibes to give. she's not about to write into the void, periodt.


πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • A β€” an SDL_Rect structure representing the first rectangle. the first bestie 🫢
  • B β€” an SDL_Rect structure representing the second rectangle. the other bestie 🫢
  • result β€” an SDL_Rect structure filled in with the intersection of rectangles A and B. this is where the magic lands ✨

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns true if there is an intersection, false otherwise. so like... did they overlap or not. yes or no. slay or not slay. that's the whole answer 😭


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. she's polyamorous with threads and she's thriving πŸ’š no locks, no drama, no gatekeeping.


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. if you're on anything older she simply does not exist yet, sorry babe πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

  • SDL_HasRectIntersection(3) β€” the girl who just tells you whether they overlap without giving you the receipts. sometimes that's all you need, iykyk πŸ’…

and that's the whole page bestie, no cap, you're now certified in rectangle intersection πŸŽ€βœ¨

this page came from the Simple Directmedia Layer source, running SDL 3.4.18 β€” sending you off with love from the SDL3 FUNCTIONS section, mwah πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from