From 51bf8d0820475aab023fb9257702f0b26af385c3 Mon Sep 17 00:00:00 2001 From: Matorio <209939889+Matorio@users.noreply.github.com> Date: Sat, 6 Dec 2025 23:41:30 -0500 Subject: [PATCH] GetScreenCenter New function "GetScreenCenter" returns the width and the height of the window divided by two. --- src/raylib.h | 1 + src/rcore.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index f7e81d965..23adac664 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1002,6 +1002,7 @@ RLAPI void SetWindowFocused(void); // Set window RLAPI void *GetWindowHandle(void); // Get native window handle RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height +RLAPI Vector2 GetScreenCenter(void); // Get the center of the current screen RLAPI int GetRenderWidth(void); // Get current render width (it considers HiDPI) RLAPI int GetRenderHeight(void); // Get current render height (it considers HiDPI) RLAPI int GetMonitorCount(void); // Get number of connected monitors diff --git a/src/rcore.c b/src/rcore.c index 3a9a47359..775f197f3 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -819,6 +819,17 @@ int GetScreenHeight(void) return CORE.Window.screen.height; } +// Get the center of the current screen +Vector2 GetScreenCenter(void) +{ + Vector2 center = (Vector2) + { + GetScreenWidth() / 2.0f, + GetScreenHeight() / 2.0f + }; + return center; +} + // Get current render width which is equal to screen width*dpi scale int GetRenderWidth(void) {