- Timestamp:
- 01/11/07 16:19:59 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgtessellate/osgtessellate.cpp
r5939 r5962 23 23 #include <osgDB/ReadFile> 24 24 #include <osgUtil/Optimizer> 25 #include <osg Producer/Viewer>25 #include <osgViewer/Viewer> 26 26 #include <osg/Projection> 27 27 #include <osg/MatrixTransform> … … 741 741 int main( int argc, char **argv ) 742 742 { 743 744 743 // use an ArgumentParser object to manage the program arguments. 745 744 osg::ArgumentParser arguments(&argc,argv); 746 747 // set up the usage document, in case we need to print out how to use this program.748 arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());749 arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is provides an example of doing tesseleation..");750 arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");751 arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");752 753 745 754 746 // construct the viewer. 755 osgProducer::Viewer viewer(arguments); 756 757 // set up the value with sensible default event handlers. 758 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 759 760 // get details on keyboard and mouse bindings used by the viewer. 761 viewer.getUsage(*arguments.getApplicationUsage()); 762 763 // if user request help write it out to cout. 764 if (arguments.read("-h") || arguments.read("--help")) 765 { 766 arguments.getApplicationUsage()->write(std::cout); 767 return 1; 768 } 769 770 // report any errors if they have occured when parsing the program aguments. 771 if (arguments.errors()) 772 { 773 arguments.writeErrorMessages(std::cout); 774 return 1; 775 } 776 777 osg::Timer timer; 778 osg::Timer_t start_tick = timer.tick(); 747 osgViewer::Viewer viewer; 779 748 780 749 // read the scene from the list of file specified commandline args. … … 785 754 { 786 755 loadedModel=makeTessellateExample(); 756 787 757 } else { // if there is a loaded model: 758 788 759 // tessellate by searching for geode called tessellate & tessellate it 789 760 setTessellateVisitor tsv; 790 761 loadedModel->accept(tsv); 762 791 763 } 792 764 … … 795 767 gload->addChild(createHUD()); 796 768 797 798 // any option left unread are converted into errors to write out later.799 arguments.reportRemainingOptionsAsUnrecognized();800 801 // report any errors if they have occured when parsing the program aguments.802 if (arguments.errors())803 {804 arguments.writeErrorMessages(std::cout);805 }806 807 osg::Timer_t end_tick = timer.tick();808 809 std::cout << "Time to load = "<<timer.delta_s(start_tick,end_tick)<<std::endl;810 811 769 812 770 osgUtil::Optimizer optimizer; … … 817 775 818 776 // add event handler for keyboard 'n' to retessellate 819 viewer.getEventHandlerList().push_front(new KeyboardEventHandler(loadedModel.get())); 820 821 // create the windows and run the threads. 822 viewer.realize(); 823 824 while( !viewer.done() ) 825 { 826 // wait for all cull and draw threads to complete. 827 viewer.sync(); 828 829 // update the scene by traversing it with the the update visitor which will 830 // call all node update callbacks and animations. 831 viewer.update(); 832 833 // fire off the cull and draw traversals of the scene. 834 viewer.frame(); 835 836 } 837 838 // wait for all cull and draw threads to complete. 839 viewer.sync(); 840 841 // do OpenGL clean up 842 viewer.cleanup_frame(); 843 844 // wait for all cull and draw threads to complete before exit. 845 viewer.sync(); 846 847 return 0; 777 viewer.addEventHandler(new KeyboardEventHandler(loadedModel.get())); 778 779 return viewer.run(); 848 780 } 849 781
