OpenGL and Multiple Displays

I have three display connected to my system and would like to know what is the approach to open three windows using OpenGL one on each display having different bmp contents.

I have been struggling to get an answer for this and could not get any concrete answer. Really appreciate help or links for the same.


Assume displays are layed out as follows:-

Display 1: [0, 0, 1024, 768]
Display 2: [1024, 0, 1024, 768]
Display 3: [2048, 0, 1024, 768]

Creating OpenGL windows on each display:-

  1. window1 = CreateWindow(10, 10, 256, 256);
    Create Device & Rendering context for “window1 -> (dc1, rc1)”
  2. window2 = CreateWindow(1024 + 10, 10, 256, 256);
    Create Device & Rendering context for “window2 -> (dc2, rc2)”
  3. window3 = CreateWindow(2048 + 10, 10, 256, 256);
    Create Device & Rendering context for “window3 -> (dc3, rc3)”

Drawing to each of the OpenGL windows:-

  1. MakeCurrent(dc1, rc1);
  2. MakeCurrent(dc2, rc2);
  3. MakeCurrent(dc3, rc3);

I might sound dumb, but the other constrain I am having is that out of the three displays two come from a GPU ( still not decided Matrox or NVidia ) and other from a Intel 810 chipset port. This will not let me span the displays across different chipsets, correct me if I am wrong. The OS I am using is Linux 2.6.16.

Help please !


To put the displays in span mode the displays have to be connected to the same graphics device (same GPU).

Hi DimensionX,
Thanks for the reply, so is there any other way to get this to work instead of creating a process for each display. I read something about glx, but there is not much help online. Any thoughts ?

Thanks for your help…
Really appreciate it.

Hi all
Is there any tutorial on GLX it mentions about OpenGL graphics with the X-Window System. Will this be of any help in displaying on multiple screens. Any ideas / help plz.



You may want to check the lesson #1 tutorial at At the bottom of the page, you should download the source code for the Linux/GLX version. You’ll find that you might not need a large part of that code as a lot of it deals with setting fullscreen mode.

In your case, you most likely will need to create one window per screen. You must specify the root window of the desired screen as the parent of your window when you create it in the XCreateWindow call.

And as dimensionX said, you’ll need one rendering context per window. You can switch among them and render in each one, like he suggested. That would be the way to go for a single core machine or for a simple project.
Or you can do your rendering in 3 different threads, one for each window. (rendering contexts are local to a thread).

Hope that helps a litte.