在不同窗口中显示 Dear ImGui

问题描述 投票:0回答:1

我想将 Dear ImGui 元素渲染到两个不同的 glfw 窗口。
我有来自here的示例代码:

#include <GLFW/glfw3.h>

int main(void)
{
    GLFWwindow* window1;
    GLFWwindow* window2;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window1 = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window1)
    {
        glfwTerminate();
        return -1;
    }

    /* Create a second windowed mode window and its OpenGL context */
    window2 = glfwCreateWindow(640, 480, "World Hello", NULL, NULL);
    if (!window2)
    {
        glfwTerminate();
        return -1;
    }

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window1) && !glfwWindowShouldClose(window2))
    {
        /* Make the window's context current */
        glfwMakeContextCurrent(window1);
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);
        /* Swap front and back buffers */
        glfwSwapBuffers(window1);

        /* Make the second window's context current */
        glfwMakeContextCurrent(window2);
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);
        /* Swap front and back buffers */
        glfwSwapBuffers(window2);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

如何转换此代码,以便可以在设置了 ImGui 的情况下将(不同的)ImGui 渲染到两个窗口。

c++ glfw imgui
1个回答
0
投票

您对此有任何更新吗?我也有同样的困境!

对于评论作为答案深表歉意 - 我无法添加评论。

© www.soinside.com 2019 - 2024. All rights reserved.