Multiple full screen windows on linux

I am working on an application that renders an image from camera to multiple windows.
The application is running on Ubuntu using X.
Xorg.conf is configured to use a single X-screen for all connected monitors.
Desktop is displayed across all monitors.

I am using the following calls to make the window full screen
win = glfwCreateWindow(width, height, “Name”, null, null);
glfwSetWindowPos(win, monitorOffset, 0);
glfwSetWindowMonitor(win, monitor, monitorOffset, 0 width, height, refreshRate);
If I try to create a full screen by passing the monitor during the CreateWindow call then both windows are created on the main monitor.

When I run the application on a single monitor in full screen the call to glfwSwapBuffers return immediately. When I render to 2 monitors (2 glfw Windows) in full screen, both calls to glfwSwapBuffers block for 14-16ms.

  1. Is it possible to avoid tearing running 2 full screen windows with the above configuration? As I understand it since there is only 1 X-screen the v-sync can only sync to one physical monitor.

  2. Why does the call to glfwSwapBuffers blocks in case of using more then 1 display in full screen?

If you want to avoid tearing make sure to set the swap interval, see the documentation on buffer swapping. Note that the swap interval is set for the current context, so make sure to set your context for the given window prior to this call.

Multiple vertical synced full screen windows can be difficult to manage, you may want to use separate threads to handle the rendering and swapping, with the main thread handling the even polling.

Thanks. I set the SwapInterval correctly but I still observe tear.

Any idea why the call to swapBuffers blocks when rendering to 2 displays and doesnt when rendering to only 1? In the 2 displays setup I get a block of ~15ms for the swap of 1st and also for the 2nd display

I don’t know the reason for this - however some drivers implement vertical sync application overrides in their configs, so it might be worth investigating that.