diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index d23bbac0..ece72da8 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5827,6 +5827,12 @@ GLFWAPI void glfwDestroyUserContext(GLFWusercontext* context); */ GLFWAPI void glfwMakeUserContextCurrent(GLFWusercontext* context); +/*! @brief Get the current OpenGL user context +* +*/ +GLFWAPI GLFWusercontext* glfwGetCurrentUserContext(void); + + /*! @brief Returns whether the Vulkan loader and an ICD have been found. * * This function returns whether the Vulkan loader and any minimally functional diff --git a/src/context.c b/src/context.c index 6e558d55..8db76c84 100644 --- a/src/context.c +++ b/src/context.c @@ -802,3 +802,9 @@ GLFWAPI void glfwMakeUserContextCurrent(GLFWusercontext* handle) if (context) context->makeCurrent(context); } + +GLFWAPI GLFWusercontext* glfwGetCurrentUserContext(void) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return _glfwPlatformGetTls(&_glfw.usercontextSlot); +} \ No newline at end of file