int main(int argc, char** argv) { osg::ArgumentParser arguments(&argc, argv); osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments); std::string path = osgDB::getFilePath(""); if(!loadedModel) loadedModel = osgDB::readRefNodeFile(""); if(!loadedModel) { std::cout << arguments.getApplicationName() << std::endl; return 1; } osgViewer::Viewr viewer; int xoffset = 40; int yoffset = 40; // left window + left slave camera { osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; traits->x = xoffset + 0; traits->y = yoffset + 0; traits->width = 600; traits->height = 480; traits->windowDecoration = true; traits->doubleBuffer = true; traits->sharedContext = 0; traits->readDISPLAY(); traits->setUndefinedScreenDetailsToDefaultScreen(); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::Camera> camera = new osg::Camera; camera->setGraphicsContext(gc.get()); camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height)); GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; camera->setDrawBuffer(buffer); camera->setReadBuffer(buffer); viewer.addSlave(camera.get(), osg::Matrixd::translate(1.0, 0.0, 0.0), osg::Matrixd()); } // right window + right slave camera { osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; traits->x = xoffset + 600; traits->y = yoffset + 0; traits->width = 600; traits->height = 480; traits->windowDecoration = true; traits->doubleBuffer = true; traits->sharedContext = 0; traits->readDISPLAY(); traits->setUndefinedScreenDetailsToDefaultScreen(); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::Camera> camear = new osg::Camera; camera->setGraphicsContext(gc.get()); camera->setViewport(new osg::Viewport(0.0, traits->width, traits->height)); GLenum buffer = traits->doubleBuffer ? GL_BACK :GL_FRONT; camera->setDrawBuffer(buffer); camera->setReadBuffer(buffer); viewer.addSlave(camear.get(), osg::Matrixd::translate(-1.0, 0.0, 0.0), osg::Matrixd()); } osgUtil::Optimizer optimizer; optimizer.optimize(loadedmodel); viewer.setSceneDat(loadedModel); return viewer.run(); }