// Initialize GLUT & OpenSG and set up the scene int main(int argc, char **argv) { char *opt; NodePtr scene=NullFC; // OSG init ChangeList::setReadWriteDefault(); osgInit(argc,argv); // GLUT init int winid = setupGLUT(&argc, argv); // the connection between this client and the servers mwin= SortLastWindow::create(); // all changes must be enclosed in beginEditCP and endEditCP // otherwise the changes will not be transfered over the network. beginEditCP(mwin); // evaluate params for(int a=1 ; a<argc ; ++a) { if(argv[a][0] == '-') { switch(argv[a][1]) { case 'm': mwin->setConnectionType("Multicast"); cout << "Connection type set to Multicast" << endl; break; case 'p': mwin->setConnectionType("SockPipeline"); cout << "Connection type set to SockPipeline" << endl; break; case 'i': opt = argv[a][2] ? argv[a]+2 : argv[++a]; if(opt != argv[argc]) mwin->setConnectionInterface(opt); break; case 'a': opt = argv[a][2] ? argv[a]+2 : argv[++a]; if(opt != argv[argc]) mwin->setServiceAddress(opt); break; case 'f': opt = argv[a][2] ? argv[a]+2 : argv[++a]; if(opt != argv[argc]) scene = SceneFileHandler::the().read( opt,0); break; default: std::cout << argv[0] << " -m" << " -p" << " -i interface" << " -f file" << endLog; return 0; } } else { printf("%s\n",argv[a]); mwin->getServers().push_back(argv[a]); } } // Set the composer to use mwin->setComposer(PipelineComposer::create()); // window size mwin->setSize(800,600); // Create/set the client window that will display the result clientWindow = GLUTWindow::create(); beginEditCP(clientWindow); glutReshapeWindow(800,600); clientWindow->setId(winid); clientWindow->init(); endEditCP(clientWindow); clientWindow->resize(800,600); // Set the client window that will display the result mwin->setClientWindow(clientWindow); // end edit of cluster window endEditCP(mwin); // create default scene if(scene == NullFC) { scene = makeNodeFor(Group::create()); beginEditCP(scene); scene->addChild(makeTorus(.5, 2, 16, 16)); scene->addChild(makeCylinder(1, .3, 8, true, true, true)); endEditCP(scene); } // create the SimpleSceneManager helper mgr = new SimpleSceneManager; // tell the manager what to manage mgr->setWindow(mwin ); mgr->setRoot (scene); // show the whole scene mgr->showAll(); // initialize window mwin->init(); // GLUT main loop glutMainLoop(); return 0; }
// react to size changes void reshape(int w, int h) { clientWindow->resize(w,h); // Modified for VizStack. Handle rezise mwin->resize(w,h); // Modified for VizStack. Handle rezise glutPostRedisplay(); }