Glut on x display

Hi,
I have a smal problem. I making aplication in to the CAVE. There is more than one display. I can make glut aplication that is in one display. But now I try to create aplikaction in to 2 display. I try this with putenv. But both of this windows are in first one. I think that is caused by glutInit. Firstly I call putenv(“DISPLAY=:0.1”); which make first window on first display, but I supposed that putenv(“DISPLAY=:0.0”) make second window in to second display but it isnt . It is still in first display. I think that after I call glutinit, program will save display and all of other windows display here. But glutinit i call just once. So can anybody help me with this problem please ?


putenv("DISPLAY=:0.1"); //display 1

    glutInit(&argc, argv);
    //glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STEREO); //stereo vizual

    //glutInitWindowPosition(5, 5);
    //glutInitWindowSize(WIDTH, HEIGHT);
    glutInitWindowPosition(5, 5);
    glutInitWindowSize(600, 450);


    // window0
    /* Create main window and set callbacks. */

   
    int id_w1 = glutCreateWindow("vokno1");

    this->win = id_w1;
    windows[0] = id_w1;
    active_windows[0] = true;

    glutDisplayFunc(myDisplay);
    glutReshapeFunc(myReshape);

    glutIdleFunc(myIdle);

    /* Create main menu. */
    glutCreateMenu(myMenu);
    glutAddMenuEntry("Quit", 99);

    /* Menu will be invoked by the right mouse button */
    glutAttachMenu(GLUT_RIGHT_BUTTON);



    init();
  
    //wokno 2----
     glutInitWindowPosition(200, 5);
    glutInitWindowSize(600, 450);
    
    putenv("DISPLAY=:0.0"); //display 0

    int id_w2 = glutCreateWindow("vokno2");
    //this->win = id_w2;
    windows[1] = id_w2;
    active_windows[1] = true;


  glutDisplayFunc(myDisplay);
  glutReshapeFunc(myReshape);

  //glutIdleFunc(myIdle);

  //glutCreateMenu(myMenu);
  //glutAddMenuEntry("Quit w2", 1);

  //glutAddMenuEntry("hide w2", 7);
  //glutAddMenuEntry("show w2", 8);

  init();
  

    /* Run endless main loop to process events. */
    glutMainLoop();

PS sorry for mistake my english is quite bad :slight_smile:

AFAIK with separate X displays, each program is tied to only one screen which is determined at startup, so you would have to run 1 program per screen, and send message between programs for synchronization.

Tools like Xinerama or RandR (or TwinView on Nvidia) will help, by considering all physical screens in a single large X virtual screen, avoiding the need for separate programs.

thanks a lot,
Xinerama looks good but can you help me how to use it ? I didnt find any source how to install just ftp://ftp.xfree86.org/pub/XFree86/4.0/ but it didnt work

It is often simpler to rely on your Linux distribution to handle this, than try to compile X by yourself.

So, what distribution do use ?
Which version ?
Which video hardware ?
Which graphic drivers ?
Whats is the output of :
glxinfo | head; glxinfo |grep OpenGL

ok just wait for a while. I must find out this information because that is school’s server.

You can do this in separate threads within the same program as well. In each thread, create separate connections to the X server pointing to different screens (e.g. :0.0, :0.1, :0.2, etc.), and create a GLX context in each to talk OpenGL to the X server:

You could also jam these N X connections and N GLX contexts and associated drawing all in one thread as well, rendering to each serially, with the obvious loss in performance associated with doing embarrassingly parallel work in series.

And of course, as ZbuffeR said, you could assign totally separate programs to render to each screen as well.

yea I was thinking about seperate threads but I dont know how can do this because create threads with technology such as Qt isnt my bussines

Surely you can create threads outside of Qt?