【发布时间】:2017-07-21 17:13:09
【问题描述】:
我正在尝试在 Windows 上制作 OpenGL 程序。由于主 exe 文件越来越大,我决定将其拆分为 DLL。这就是我的问题的开始。
对于 ImGui 函数,我创建了一个类。这是我班级的 render() 函数:
cout << "render" << endl;
imgui_newFrame();
{
ImGui::SetNextWindowSize(ImVec2(30, 30), ImGuiSetCond_FirstUseEver);
ImGui::Begin("Test", &show_another_window);
ImGui::Button("Test Window");
ImGui::End();
}
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
ImGui::Render();
在我的类中调用 render() 函数之前,我在我的类中的另一个函数中启动 ImGui:
if (!imgui_init(glfw_window)) {
return false;
}
这是我的主要 glfw 循环:
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
MyMyGuiClass.render(); //here i ask my class to render imgui
glfwSwapBuffers(window);
}
使用此代码,我可以使 ImGui 清除窗口颜色(glClearColor 功能有效,我的控制台打印“渲染”)
但它没有显示任何其他内容。
顺便说一下,这是我运行时完美运行的命令。
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
imgui_newFrame();
{
ImGui::SetNextWindowSize(ImVec2(30, 30), ImGuiSetCond_FirstUseEver);
ImGui::Begin("", &show_another_window);
ImGui::Button("Test Window");
ImGui::End();
}
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
ImGui::Render();
glfwSwapBuffers(window);
}
我使用的是 VS2017,我的编译器在编译时没有显示任何警告或错误。我也试图让我的班级的功能静态,但我什么也没得到。
这么简单,ImGui 在类内部调用时是否无法呈现?
【问题讨论】:
-
"由于主 exe 文件越来越大,我决定将其拆分为 DLL。"这不是 DLL 应该解决的问题(库重用等)。无论如何都会加载所有内容。
-
调试和构建一个巨大的 exe 需要时间。这就是我想说的。