【发布时间】:2017-09-11 09:21:53
【问题描述】:
【问题讨论】:
标签: opengl visual-c++ mfc glfw
【问题讨论】:
标签: opengl visual-c++ mfc glfw
试试这个:
glfwWindowHint()将GLFW_DECORATED和GLFW_VISIBLE设置为false。glfwCreateWindow()。glfwGetWin32Window() 获取OpenGL 窗口的本机句柄。 SetParent() 将您的表单设置为 OpenGL 窗口的新父级。GetWindowLong() / SetWindowLong() 删除WS_POPUP 并为OpenGL 窗口添加WS_CHILDWINDOW 样式。ShowWindow() 最终使OpenGL 窗口可见。我是从 github.com/Chronial/foo_chronflow :: EngineWindow.cpp 那里得到的。
您也可以调用 SetWindowPos() 来调整 OpenGL 窗口在表单中的位置。
【讨论】:
zett42 帖子中的链接已经失效,所以这里有一个更完整的 sn-p
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
GLFWwindow* pWindow = glfwCreateWindow(width, height, "", NULL, NULL);
HWND hwNative = glfwGetWin32Window(m_pWindow);
SetParent(hwNative, hwParentWindow);
long style = GetWindowLong(hwNative, GWL_STYLE);
style &= ~WS_POPUP; // remove popup style
style |= WS_CHILDWINDOW; // add childwindow style
SetWindowLong(hwNative, GWL_STYLE, style);
... any other initialisation code (e.g enable/disable gl features) ...
ShowWindow(hwNative, SW_SHOW);
【讨论】: