小编Rom*_*men的帖子

GLFW & ImGui:从主线程以外的线程创建 ImGui 控件

我正在将 GLFW 和 ImGui 用于涉及打开多个窗口的项目。到目前为止,我已经进行了设置,以便每次必须打开新窗口时,我都会生成一个线程来创建自己的 GLFW 窗口和 OpenGL 上下文。线程函数看起来像这样:

window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
// Check for creation error...
glfwMakeContextCurrent(window);

ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();   // Is this supposed to be done per-thread?
// Calling specific impl-specific ImGui setup methods for GLFW & OpenGL3...
// Set up OpenGL stuff ...

while (!glfwWindowShouldClose(window))
{
    // Some heavy-duty processing happens here...

    ImGui_ImplOpenGL3_NewFrame();
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();

    // ImGui code is here...

    // Rendering some stuff in the window here...

    // Render …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading glfw imgui

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

glfw ×1

imgui ×1

multithreading ×1