- Timestamp:
- 01/06/07 22:35:57 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgdepthpartition/osgdepthpartition.cpp
r5054 r5923 1 //C++ source file - Open Producer - Copyright (C) 2002 Don Burns2 //Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)3 //as published by the Free Software Foundation.4 5 // Simple example of use of Producer::RenderSurface6 // The myGraphics class is a simple sample of how one would implement7 // graphics drawing with Producer::RenderSurface8 9 1 #include <osgUtil/UpdateVisitor> 10 2 … … 14 6 #include <osg/PositionAttitudeTransform> 15 7 16 #include <osgProducer/Viewer> 8 #include <osgGA/TrackballManipulator> 9 10 #include <osgViewer/Viewer> 17 11 18 12 #include "DepthPartitionNode.h" … … 63 57 // use an ArgumentParser object to manage the program arguments. 64 58 osg::ArgumentParser arguments(&argc,argv); 65 66 // set up the usage document, in case we need to print out how to use this program.67 arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());68 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard example of using osgProducer::CameraGroup.");69 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] ...");70 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");71 59 72 60 // construct the viewer. 73 osgProducer::Viewer viewer(arguments); 74 75 // set up the value with sensible default event handlers. 76 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 77 78 // if user request help write it out to cout. 79 if (arguments.read("-h") || arguments.read("--help")) 80 { 81 arguments.getApplicationUsage()->write(std::cout); 82 return 1; 83 } 84 85 // any option left unread are converted into errors to write out later. 86 arguments.reportRemainingOptionsAsUnrecognized(); 87 88 // report any errors if they have occured when parsing the program aguments. 89 if (arguments.errors()) 90 { 91 arguments.writeErrorMessages(std::cout); 92 return 1; 93 } 94 61 osgViewer::Viewer viewer; 95 62 96 63 bool needToSetHomePosition = false; … … 114 81 viewer.setSceneData(dpn.get()); 115 82 83 viewer.setCameraManipulator(new osgGA::TrackballManipulator); 84 116 85 if (needToSetHomePosition) 117 86 { 118 viewer.getKeySwitchMatrixManipulator()->setHomePosition(osg::Vec3d(0.0,-5.0*r_earth,0.0),osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,0.0,1.0)); 119 } 120 121 // create the windows and run the threads. 122 viewer.realize(); 123 124 while( !viewer.done() ) 125 { 126 // wait for all cull and draw threads to complete. 127 viewer.sync(); 128 129 // update the scene by traversing it with the the update visitor which will 130 // call all node update callbacks and animations. 131 viewer.update(); 132 133 // fire off the cull and draw traversals of the scene. 134 viewer.frame(); 135 87 viewer.getCameraManipulator()->setHomePosition(osg::Vec3d(0.0,-5.0*r_earth,0.0),osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,0.0,1.0)); 136 88 } 137 89 138 // wait for all cull and draw threads to complete before exit.139 viewer.s ync();90 // depth partion node is only supports single window/single threaded at present. 91 viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded); 140 92 141 // run a clean up frame to delete all OpenGL objects. 142 viewer.cleanup_frame(); 143 144 // wait for all the clean up frame to complete. 145 viewer.sync(); 146 147 return 0; 93 return viewer.run(); 148 94 } 149 95
