From 1268d0ce085e1cac0e45922320801a6aba8f565b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 5 Jan 2007 16:24:05 +0000 Subject: [PATCH] Ported osgcegui across to osgViewer --- examples/osgcegui/GNUmakefile | 2 +- examples/osgcegui/GNUmakefile.inst | 4 +- examples/osgcegui/osgcegui.cpp | 77 +++--------------------------- 3 files changed, 9 insertions(+), 74 deletions(-) diff --git a/examples/osgcegui/GNUmakefile b/examples/osgcegui/GNUmakefile index 99868a74a..0e550ebdc 100644 --- a/examples/osgcegui/GNUmakefile +++ b/examples/osgcegui/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgcegui.cpp\ -LIBS += -lCEGUIBase -lCEGUIOpenGLRenderer -losgProducer -lProducer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -lCEGUIBase -lCEGUIOpenGLRenderer -losgViewer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgcegui/GNUmakefile.inst b/examples/osgcegui/GNUmakefile.inst index 809fee481..d2a8962f2 100644 --- a/examples/osgcegui/GNUmakefile.inst +++ b/examples/osgcegui/GNUmakefile.inst @@ -4,9 +4,9 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgcegui.cpp\ -LIBS += -lCEGUIBase -lCEGUIOpenGLRenderer -losgProducer -lProducer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -lCEGUIBase -lCEGUIOpenGLRenderer -losgViewer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) -EXEC = osgviewer +EXEC = osgcegui INC += -I/usr/local/include/CEGUI diff --git a/examples/osgcegui/osgcegui.cpp b/examples/osgcegui/osgcegui.cpp index e746d9a2d..3b1b6110f 100644 --- a/examples/osgcegui/osgcegui.cpp +++ b/examples/osgcegui/osgcegui.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -23,6 +23,8 @@ #include #include +#include + class CEGUIDrawable : public osg::Drawable { public: @@ -204,38 +206,10 @@ int main( int argc, char **argv ) // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); - // set up the usage document, in case we need to print out how to use this program. - arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); - arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models."); - arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); - arguments.getApplicationUsage()->addCommandLineOption("--image ","Load an image and render it on a quad"); - arguments.getApplicationUsage()->addCommandLineOption("--dem ","Load an image/DEM and render it on a HeightField"); - arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters"); - arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available"); - arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available"); - - arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings."); - // construct the viewer. - osgProducer::Viewer viewer(arguments); + osgViewer::Viewer viewer; - // set up the value with sensible default event handlers. - viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); - - // get details on keyboard and mouse bindings used by the viewer. - viewer.getUsage(*arguments.getApplicationUsage()); - - // if user request help write it out to cout. - bool helpAll = arguments.read("--help-all"); - unsigned int helpType = ((helpAll || arguments.read("-h") || arguments.read("--help"))? osg::ApplicationUsage::COMMAND_LINE_OPTION : 0 ) | - ((helpAll || arguments.read("--help-env"))? osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE : 0 ) | - ((helpAll || arguments.read("--help-keys"))? osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING : 0 ); - if (helpType) - { - arguments.getApplicationUsage()->write(std::cout, helpType); - return 1; - } osg::ref_ptr geode = new osg::Geode; osg::ref_ptr cd = new CEGUIDrawable(); @@ -259,20 +233,6 @@ int main( int argc, char **argv ) cd->loadLayout(layout); } - - // report any errors if they have occurred when parsing the program arguments. - if (arguments.errors()) - { - arguments.writeErrorMessages(std::cout); - return 1; - } - - if (arguments.argc()<=1) - { - arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); - return 1; - } - osg::Timer_t start_tick = osg::Timer::instance()->tick(); // read the scene from the list of file specified command line args. @@ -312,32 +272,7 @@ int main( int argc, char **argv ) // pass the loaded scene graph to the viewer. viewer.setSceneData(group.get()); - // create the windows and run the threads. - viewer.realize(); - - while( !viewer.done() ) - { - // wait for all cull and draw threads to complete. - viewer.sync(); - - // update the scene by traversing it with the the update visitor which will - // call all node update callbacks and animations. - viewer.update(); - - // fire off the cull and draw traversals of the scene. - viewer.frame(); - - } - - // wait for all cull and draw threads to complete. - viewer.sync(); - - // run a clean up frame to delete all OpenGL objects. - viewer.cleanup_frame(); - - // wait for all the clean up frame to complete. - viewer.sync(); - - return 0; + // run the viewer + return viewer.run(); }