如何使用 GLFWwindow 指针获取 HWND?

How to get HWND with GLFWwindow pointer?

我有一个 GLFWwindow 的指针(它是 glfw3.h 中定义的一个结构,似乎是一个 openGL 结构?)。如何使用指针获取HWND?

GLFW 有一个关于 native access 的部分,在那里你可以找到这个函数,它允许你检索 HWND:

HWND glfwGetWin32Window ( GLFWwindow * window):

Returns
The HWND of the specified window, or NULL if an error occurred.
Thread safety
This function may be called from any thread. Access is not synchronized.
Since
Added in version 3.0.

请仔细阅读文档:

By using the native access functions you assert that you know what you're doing and how to fix problems caused by using them. If you don't, you shouldn't be using them.
Before the inclusion of glfw3native.h, you may define zero or more window system API macro and zero or more context creation API macros.
The chosen backends must match those the library was compiled for. Failure to do this will cause a link-time error.