From 0fc6fa88b3da7dbedda59134f1645ce598ba6bdd Mon Sep 17 00:00:00 2001 From: wis31 Date: Sun, 9 Mar 2025 14:13:25 -0600 Subject: [PATCH 1/2] Add external API to query initialization status of GLFW. --- include/GLFW/glfw3.h | 20 ++++++++++++++++++++ src/init.c | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 79b06288..1ce552f3 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2254,6 +2254,26 @@ GLFWAPI int glfwInit(void); */ GLFWAPI void glfwTerminate(void); +/*! @brief Queries if the GLFW library is intialized. + * + * This function queries whether the GLFW libarary is in an initialized state. + * The library is considered to be in an initialized state + * when @ref glfwInit is invoked successfully, and @ref glfwTerminate has not been invoked after. + * + * @return `GLFW_TRUE` if the library is intialized, or `GLFW_FALSE` if otherwise. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref intro_init + * @sa @ref glfwInit + * @sa @ref glfwTerminate + * + * @since Added in version 3.4. + * + * @ingroup init + */ +GLFWAPI int glfwIsInitialized(void); + /*! @brief Sets the specified init hint to the desired value. * * This function sets hints for the next initialization of GLFW. diff --git a/src/init.c b/src/init.c index dbd5a900..cc682ea8 100644 --- a/src/init.c +++ b/src/init.c @@ -437,6 +437,13 @@ GLFWAPI void glfwTerminate(void) terminate(); } +GLFWAPI int glfwIsInitialized(void){ + if (_glfw.initialized) + return GLFW_TRUE; + + return GLFW_FALSE; +} + GLFWAPI void glfwInitHint(int hint, int value) { switch (hint) From 06137147a34d412ae3198a97217e1c421b64dd74 Mon Sep 17 00:00:00 2001 From: Abhi <53955280+abhi-k9@users.noreply.github.com> Date: Wed, 12 Mar 2025 14:58:28 -0600 Subject: [PATCH 2/2] Simplify code logic for `glfwIsInitialized`. --- src/init.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/init.c b/src/init.c index cc682ea8..8e12377e 100644 --- a/src/init.c +++ b/src/init.c @@ -437,11 +437,9 @@ GLFWAPI void glfwTerminate(void) terminate(); } -GLFWAPI int glfwIsInitialized(void){ - if (_glfw.initialized) - return GLFW_TRUE; - - return GLFW_FALSE; +GLFWAPI int glfwIsInitialized(void) +{ + return _glfw.initialized; } GLFWAPI void glfwInitHint(int hint, int value)