I’m trying to create 2 windows in fullscreen mode for 2 external monitors with GLFW. My program runs and output 2 windows in 2 monitors but 1 of them need to be minimized and cannot be both displayed at the same time.
I suspect it is because of switching context between the two windows that make it unable to run both but I’m not sure.
My code is below. windows size are corresponding to the monitors that they’re being created. Anyone has ideas about this?
// glfw window creation
// --------------------
//WINDOW 1 AT MONITOR 1
GLFWwindow* window = glfwCreateWindow(mode1->width, mode1->height, "LearnOpenGL", m1, NULL);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
//WINDOW 2 AT MONITOR 2
GLFWwindow* window2 = glfwCreateWindow(mode2->width,mode2->height,"LearnOpenGL2", m1,NULL);
glfwSetFramebufferSizeCallback(window2, framebuffer_size_callback);
while (!glfwWindowShouldClose(window) )
{
glfwMakeContextCurrent(window);
glClearColor(0.2f, 0.7f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwMakeContextCurrent(window2);
glClearColor(0.7f, 0.1f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwSwapBuffers(window2);
glfwPollEvents();
}