Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在不同窗口中显示亲爱的ImGui_C++_Glfw_Imgui - Fatal编程技术网

C++ 在不同窗口中显示亲爱的ImGui

C++ 在不同窗口中显示亲爱的ImGui,c++,glfw,imgui,C++,Glfw,Imgui,我想将亲爱的ImGui元素呈现给两个不同的glfw窗口。 我的示例代码来自: #包括 内部主(空) { GLFWwindow*window1; GLFWwindow*window2; /*初始化库*/ 如果(!glfwInit()) 返回-1; /*创建窗口模式窗口及其OpenGL上下文*/ window1=glfwCreateWindow(640480,“你好世界”,空,空); 如果(!window1) { glfwTerminate(); 返回-1; } /*创建第二个窗口模式窗口及其Ope

我想将亲爱的ImGui元素呈现给两个不同的glfw窗口。
我的示例代码来自:

#包括
内部主(空)
{
GLFWwindow*window1;
GLFWwindow*window2;
/*初始化库*/
如果(!glfwInit())
返回-1;
/*创建窗口模式窗口及其OpenGL上下文*/
window1=glfwCreateWindow(640480,“你好世界”,空,空);
如果(!window1)
{
glfwTerminate();
返回-1;
}
/*创建第二个窗口模式窗口及其OpenGL上下文*/
window2=glfwCreateWindow(640480,“世界你好”,空,空);
如果(!window2)
{
glfwTerminate();
返回-1;
}
/*循环,直到用户关闭窗口*/
而(!glfwWindowShouldClose(窗口1)和&!glfwWindowShouldClose(窗口2))
{
/*将窗口的上下文设置为当前*/
glfwMakeContextCurrent(窗口1);
/*在这里渲染*/
glClear(GLU颜色缓冲位);
/*交换前后缓冲区*/
glfwSwapBuffers(窗口1);
/*将第二个窗口的上下文设置为当前*/
glfwMakeContextCurrent(window2);
/*在这里渲染*/
glClear(GLU颜色缓冲位);
/*交换前后缓冲区*/
glfwSwapBuffers(窗口2);
/*轮询并处理事件*/
glfwPollEvents();
}
glfwTerminate();
返回0;
}
如果设置了ImGui,如何转换此代码以便将(不同的)ImGui呈现到两个窗口

#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;
}