From 5adcc30a2e3984d2df59e228c9360edf47f63c7a Mon Sep 17 00:00:00 2001 From: Marco Lizza Date: Thu, 10 Jan 2019 14:54:55 +0100 Subject: [PATCH 1/4] Adding window visibility configuration flag. --- src/core.c | 3 +++ src/raylib.h | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core.c b/src/core.c index 79404abe..b34afeff 100644 --- a/src/core.c +++ b/src/core.c @@ -2247,6 +2247,9 @@ static bool InitGraphicsDevice(int width, int height) //glfwWindowHint(GLFW_AUX_BUFFERS, 0); // Number of auxiliar buffers // Check some Window creation flags + if (configFlags & FLAG_WINDOW_HIDDEN) glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // Visible window + else glfwWindowHint(GLFW_VISIBLE, GL_TRUE); // Window initially hidden + if (configFlags & FLAG_WINDOW_RESIZABLE) glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // Resizable window else glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // Avoid window being resizable diff --git a/src/raylib.h b/src/raylib.h index 430e66db..9e254f97 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -410,8 +410,9 @@ typedef enum { FLAG_WINDOW_RESIZABLE = 4, // Set to allow resizable window FLAG_WINDOW_UNDECORATED = 8, // Set to disable window decoration (frame and buttons) FLAG_WINDOW_TRANSPARENT = 16, // Set to allow transparent window - FLAG_MSAA_4X_HINT = 32, // Set to try enabling MSAA 4X - FLAG_VSYNC_HINT = 64 // Set to try enabling V-Sync on GPU + FLAG_WINDOW_HIDDEN = 32, // Set to create the window initially hidden + FLAG_MSAA_4X_HINT = 64, // Set to try enabling MSAA 4X + FLAG_VSYNC_HINT = 128 // Set to try enabling V-Sync on GPU } ConfigFlag; // Trace log type From a15251bcdbcf5f89af3a5b2189aafcc8444948ab Mon Sep 17 00:00:00 2001 From: Marco Lizza Date: Thu, 10 Jan 2019 14:55:19 +0100 Subject: [PATCH 2/4] Adding window visibility functions. --- src/core.c | 18 ++++++++++++++++++ src/raylib.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/core.c b/src/core.c index b34afeff..36d71fd7 100644 --- a/src/core.c +++ b/src/core.c @@ -831,6 +831,24 @@ void SetWindowSize(int width, int height) #endif } +// Set window visibility +void SetWindowVisible(bool visible) +{ +#if defined(PLATFORM_DESKTOP) + if (visible) glfwShowWindow(window); + else glfwHideWindow(window); +#endif +} + +// Set window visibility +bool IsWindowVisible() +{ +#if defined(PLATFORM_DESKTOP) + return glfwGetWindowAttrib(window, GLFW_VISIBLE) != GL_FALSE; +#endif + return true; +} + // Get current screen width int GetScreenWidth(void) { diff --git a/src/raylib.h b/src/raylib.h index 9e254f97..0eda48c3 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -827,6 +827,8 @@ 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 SetWindowVisible(bool visible); // Set window visibility +RLAPI bool IsWindowVisible(); // Check if window is currently visible RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height RLAPI void *GetWindowHandle(void); // Get native window handle From c7437342350168ca1cfa299df33b19cc3859346f Mon Sep 17 00:00:00 2001 From: Marco Lizza Date: Thu, 10 Jan 2019 14:55:25 +0100 Subject: [PATCH 3/4] Ditto. --- projects/Notepad++/raylib_npp_parser/raylib_to_parse.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h index 5dfb5dfe..84c21635 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +++ b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h @@ -15,6 +15,8 @@ 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 SetWindowVisible(bool visible); // Set window visibility +RLAPI bool IsWindowVisible(); // Check if window is currently visible RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height From 6056a2a5cf2aa939a10e807e452ed43d4b67f1ce Mon Sep 17 00:00:00 2001 From: Marco Lizza Date: Thu, 10 Jan 2019 16:43:21 +0100 Subject: [PATCH 4/4] Reworking API upon suggestion. --- .../raylib_npp_parser/raylib_to_parse.h | 5 ++-- src/core.c | 23 ++++++++++++------- src/raylib.h | 5 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h index 84c21635..d492d249 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +++ b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h @@ -15,8 +15,9 @@ 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 SetWindowVisible(bool visible); // Set window visibility -RLAPI bool IsWindowVisible(); // Check if window is currently visible +RLAPI void ShowWindow(); // Show the window +RLAPI void HideWindow(); // Hide the window +RLAPI bool IsWindowHidden(); // Check if window is currently hidden RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height diff --git a/src/core.c b/src/core.c index 36d71fd7..50666335 100644 --- a/src/core.c +++ b/src/core.c @@ -831,22 +831,29 @@ void SetWindowSize(int width, int height) #endif } -// Set window visibility -void SetWindowVisible(bool visible) +// Show the window +void ShowWindow() { #if defined(PLATFORM_DESKTOP) - if (visible) glfwShowWindow(window); - else glfwHideWindow(window); + glfwShowWindow(window); #endif } -// Set window visibility -bool IsWindowVisible() +// Hide the window +void HideWindow() { #if defined(PLATFORM_DESKTOP) - return glfwGetWindowAttrib(window, GLFW_VISIBLE) != GL_FALSE; + glfwHideWindow(window); #endif - return true; +} + +// Check if window is currently hidden +bool IsWindowHidden() +{ +#if defined(PLATFORM_DESKTOP) + return glfwGetWindowAttrib(window, GLFW_VISIBLE) == GL_FALSE; +#endif + return false; } // Get current screen width diff --git a/src/raylib.h b/src/raylib.h index 0eda48c3..f5380fbf 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -827,8 +827,9 @@ 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 SetWindowVisible(bool visible); // Set window visibility -RLAPI bool IsWindowVisible(); // Check if window is currently visible +RLAPI void ShowWindow(); // Show the window +RLAPI void HideWindow(); // Hide the window +RLAPI bool IsWindowHidden(); // Check if window is currently hidden RLAPI int GetScreenWidth(void); // Get current screen width RLAPI int GetScreenHeight(void); // Get current screen height RLAPI void *GetWindowHandle(void); // Get native window handle