From d91b9171fa4d81dab8bcb84dc7e90a69fc908510 Mon Sep 17 00:00:00 2001 From: Tushar Singh <81076342+tusharsingh09@users.noreply.github.com> Date: Thu, 30 Dec 2021 17:43:50 +0530 Subject: [PATCH] [Feature] Added SetWindowOpacity(float opacity) (#2254) * Added drawing text with shadow * Added SetWindowOpacity() * Edited Mis-spell * Fixed conventions --- src/raylib.h | 1 + src/rcore.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index c936afeda..9be3e482d 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -925,6 +925,7 @@ RLAPI void SetWindowPosition(int x, int y); // Set window RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) RLAPI void SetWindowSize(int width, int height); // Set window dimensions +RLAPI void SetWindowOpacity(float opacity); // Set window opacity, value opacity is between 0.0 and 1.0 (only PLATFORM_DESKTOP) RLAPI void *GetWindowHandle(void); // Get native window handle RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height diff --git a/src/rcore.c b/src/rcore.c index 0a89df0b7..c29356345 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1575,6 +1575,16 @@ void SetWindowSize(int width, int height) #endif } +// Set window opacity, value opacity is between 0.0 and 1.0 +void SetWindowOpacity(float opacity) +{ +#if defined(PLATFORM_DESKTOP) + if (opacity >= 1.0f) opacity = 1.0f; + else if (opacity <= 0.0f) opacity = 0.0f; + glfwSetWindowOpacity(CORE.Window.handle, opacity); +#endif +} + // Get current screen width int GetScreenWidth(void) {