From f2806aa9abd9d15be35c2e8552733773f13f9b73 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Wed, 15 Jul 2020 13:19:33 +0100 Subject: [PATCH] Added glfwGetCurrentUserContext --- include/GLFW/glfw3.h | 6 ++++++ src/context.c | 6 ++++++ 2 files changed, 12 insertions(+) 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