Win32: Expose native HDC with glfwGetWGLContextDC

This commit is contained in:
Timo Suoranta 2021-06-10 11:44:24 +03:00
parent 114776a246
commit bbf1a617b0
2 changed files with 27 additions and 0 deletions

View File

@ -185,6 +185,20 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
* @ingroup native
*/
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
/*! @brief Returns the `HDC` of the specified window.
*
* @return The `HDC` of the specified window, or `NULL` if an
* [error](@ref error_handling) occurred.
*
* @thread_safety This function may be called from any thread. Access is not
* synchronized.
*
* @since Added in version 3.TODO.
*
* @ingroup native
*/
GLFWAPI HDC glfwGetWGLContextDC(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_COCOA)

View File

@ -796,3 +796,16 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
return window->context.wgl.handle;
}
GLFWAPI HDC glfwGetWGLContextDC(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL;
}
return window->context.wgl.dc;
}