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