rem: sbkgnd->getMFSkyColor()->addValue(Color3f(1, 0, 0)); sbkgnd->getMFSkyAngle()->addValue(Pi / 2); sbkgnd->getMFSkyColor()->addValue(Color3f(0, 1, 0)); sbkgnd->getMFSkyAngle()->addValue(Pi); sbkgnd->getMFSkyColor()->addValue(Color3f(0, 0, 1));
add: sbkgnd->getMFSkyColor()->push_back(Color3f(1, 0, 0)); sbkgnd->getMFSkyAngle()->push_back(Pi / 2); sbkgnd->getMFSkyColor()->push_back(Color3f(0, 1, 0)); sbkgnd->getMFSkyAngle()->push_back(Pi); sbkgnd->getMFSkyColor()->push_back(Color3f(0, 0, 1));
context: int main (int argc, char **argv){    osgInit(argc,argv);    // GLUT init    glutInit(&argc, argv);    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);    int winid = glutCreateWindow("OpenSG");    glutKeyboardFunc(key);    glutVisibilityFunc(vis);    glutReshapeFunc(reshape);    glutDisplayFunc(display);           glutMouseFunc(mouse);       glutMotionFunc(motion);         glutIdleFunc(display);      if ( argc > 1 && isdigit(argv[1][0]) )    {        nhviewports = atoi( argv[1] );        argv++;        argc--;    }    if ( argc > 1 && isdigit(argv[1][0]) )    {        nvviewports = atoi( argv[1] );        argv++;        argc--;    }    else        nvviewports = nhviewports;            // glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );        glEnable( GL_DEPTH_TEST );    glEnable( GL_LIGHTING );    glEnable( GL_LIGHT0 );    // OSG    SceneFileHandler::the().print();    // create the graph    // beacon for camera and light      NodePtr b1n = Node::create();    GroupPtr b1 = Group::create();    beginEditCP(b1n);    b1n->setCore( b1 );    endEditCP(b1n);    // transformation    NodePtr t1n = Node::create();    TransformPtr t1 = Transform::create();    beginEditCP(t1n);    t1n->setCore( t1 );    t1n->addChild( b1n );    endEditCP(t1n);    cam_trans = t1;    // light        NodePtr dlight = Node::create();    DirectionalLightPtr dl = DirectionalLight::create();    beginEditCP(dlight);    dlight->setCore( dl );    endEditCP(dlight);        beginEditCP(dl);    dl->setAmbient( .3, .3, .3, 1 );    dl->setDiffuse( 1, 1, 1, 1 );    dl->setDirection(0,0,1);    dl->setBeacon( b1n);    endEditCP(dl);    // root    root = Node::create();    GroupPtr gr1 = Group::create();    beginEditCP(root);    root->setCore( gr1 );    root->addChild( t1n );    root->addChild( dlight );    endEditCP(root);    // Load the file    NodePtr file = NullFC;        if ( argc > 1 )        file = SceneFileHandler::the().read(argv[1]);        if ( file == NullFC )    {        cerr << "Couldn't load file, ignoring" << endl;        file = makeTorus( .5, 2, 16, 16 );        file = makeBox( 1,1,1, 1,1,1 );    }        file->updateVolume();    Vec3f min,max;    file->getVolume().getBounds( min, max );        cout << "Volume: from " << min << " to " << max << endl;    beginEditCP(dlight);    dlight->addChild( file );    endEditCP(dlight);    cerr << "Tree: " << endl;    root->dump();    // Camera        cam = PerspectiveCamera::create();    cam->setBeacon( b1n );    cam->setFov( deg2rad( 90 ) );    cam->setNear( 0.1 );    cam->setFar( 100 );    // Background#if 1 // doesn't work right now    SkyBackgroundPtr sbkgnd = SkyBackground::create();    sbkgnd->getMFSkyColor()->addValue(Color3f(1, 0, 0));    sbkgnd->getMFSkyAngle()->addValue(Pi / 2);    sbkgnd->getMFSkyColor()->addValue(Color3f(0, 1, 0));    sbkgnd->getMFSkyAngle()->addValue(Pi);    sbkgnd->getMFSkyColor()->addValue(Color3f(0, 0, 1)); #else    SolidBackgroundPtr sbkgnd = SolidBackground::create();    sbkgnd->setColor( Color3f(.5, .5, 1) );#endif        // Window    cout << "GLUT winid: " << winid << endl;    GLUTWindowPtr gwin;    GLint glvp[4];    glGetIntegerv( GL_VIEWPORT, glvp );    gwin = GLUTWindow::create();    gwin->setId(winid);    gwin->setSize( glvp[2], glvp[3] );    win = gwin;    // Viewports & Decorators    vp = new ViewportPtr [ nhviewports * nvviewports ];    deco = new TileCameraDecoratorPtr [ nhviewports * nvviewports ];        for ( int i = 0; i < nhviewports; i++ )    {        for ( int j = 0; j < nvviewports; j++ )        {            int ind = i * nvviewports + j;            vp[ind] = Viewport::create();            vp[ind]->setBackground( sbkgnd );            vp[ind]->setRoot( root );            vp[ind]->setSize(   1./nhviewports * i,1./nvviewports * j,                                 1./nhviewports * (i+1),1./nvviewports * (j+1) );            deco[ind] = TileCameraDecorator::create();            deco[ind]->setDecoratee( cam );            deco[ind]->setSize( 1./nhviewports * i,1./nvviewports * j,                                 1./nhviewports * (i+1),1./nvviewports * (j+1) );            deco[ind]->setFullSize( 800, 800 );            vp[ind]->setCamera( deco[ind] );            // for debugging: vp[ind]->setCamera( cam );            win->addPort( vp[ind] );        }    }    win->init();#if 0    // Test write, to check generic access        ofstream outFileStream( "test.osg" );    if( !outFileStream )    {        cerr << "Can not open output stream to file" << endl;        return -1;    }    OSGWriter writer( outFileStream, 4 );    writer.write( win );     #endif        // Action        ract = DrawAction::create();    ract->setFrustumCulling( false );        // tball    Vec3f pos( 0, 0, max[2] + ( max[2] - min[2] ) * 1.5 );    tball.setMode( Trackball::OSGObject );    tball.setStartPosition( pos, true );    tball.setSum( true );    tball.setTranslationMode( Trackball::OSGFree );    // run...        glutMainLoop();        return 0;}