Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How to create multiple windows on multiple displays with GLFW

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2017

    Unhappy How to create multiple windows on multiple displays with GLFW

    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?

    Code :
    // 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);

    Code :
    while (!glfwWindowShouldClose(window) )
            glClearColor(0.2f, 0.7f, 0.3f, 1.0f);
            glClearColor(0.7f, 0.1f, 0.3f, 1.0f);

  2. #2
    Member Regular Contributor
    Join Date
    May 2016
    here is the description of the window creation function:

    when creating the 2nd window, give it as last argument hte first GLFWwindow*, and specify the monitor to cover with the 2nd-last argument (instead of "m1" for both)

    Quote Originally Posted by GLFW documentation
    To create a full screen window, you need to specify the monitor the window will cover. If no monitor is specified, the window will be windowed mode. Unless you have a way for the user to choose a specific monitor, it is recommended that you pick the primary monitor. For more information on how to query connected monitors, see Retrieving monitors.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts