From cd5f0d2ccef967582fd105eb15f2d24e04d6d468 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 2 Aug 2024 18:32:13 -0700 Subject: [PATCH] Added SDL_RectToFRect() --- include/SDL3/SDL_rect.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/SDL3/SDL_rect.h b/include/SDL3/SDL_rect.h index 9735bc2a47..a61c5d5f5e 100644 --- a/include/SDL3/SDL_rect.h +++ b/include/SDL3/SDL_rect.h @@ -112,6 +112,24 @@ typedef struct SDL_FRect } SDL_FRect; +/** + * Convert an SDL_Rect to SDL_FRect + * + * \param rect a pointer to an SDL_Rect. + * \param frect a pointer filled in with the floating point representation of `rect`. + * + * \threadsafety It is safe to call this function from any thread. + * + * \since This function is available since SDL 3.0.0. + */ +SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect) +{ + frect->x = (float)rect->x; + frect->y = (float)rect->y; + frect->w = (float)rect->w; + frect->h = (float)rect->h; +} + /** * Determine whether a point resides inside a rectangle. *