diff --git a/src/Demos/osgproducer/FrameStatsHandler b/include/osgProducer/FrameStatsHandler similarity index 100% rename from src/Demos/osgproducer/FrameStatsHandler rename to include/osgProducer/FrameStatsHandler diff --git a/src/Demos/osgproducer/StatsEventHandler b/include/osgProducer/StatsEventHandler similarity index 100% rename from src/Demos/osgproducer/StatsEventHandler rename to include/osgProducer/StatsEventHandler diff --git a/include/osgProducer/Viewer b/include/osgProducer/Viewer index 6d93efd36..bb120ffa1 100644 --- a/include/osgProducer/Viewer +++ b/include/osgProducer/Viewer @@ -49,11 +49,13 @@ class OSGPRODUCER_EXPORT Viewer : public CameraGroup, public osgGA::GUIActionAda STATE_MANIPULATOR = 8, HEAD_LIGHT_SOURCE = 16, SKY_LIGHT_SOURCE = 32, + STATS_MANIPULATOR = 64, STANDARD_SETTINGS = TRACKBALL_MANIPULATOR| DRIVE_MANIPULATOR | FLIGHT_MANIPULATOR | STATE_MANIPULATOR | - HEAD_LIGHT_SOURCE + HEAD_LIGHT_SOURCE | + STATS_MANIPULATOR }; void setUpViewer(unsigned int options=STANDARD_SETTINGS); diff --git a/src/Demos/osgproducer/osgproducer_viewer.cpp b/src/Demos/osgproducer/osgproducer_viewer.cpp index b4b744775..199f05fb1 100644 --- a/src/Demos/osgproducer/osgproducer_viewer.cpp +++ b/src/Demos/osgproducer/osgproducer_viewer.cpp @@ -11,9 +11,6 @@ #include -#include "FrameStatsHandler" -#include "StatsEventHandler" - int main( int argc, char **argv ) { @@ -66,11 +63,6 @@ int main( int argc, char **argv ) // set up the value with sensible defaults. viewer->setUpViewer(); - Producer::FrameStatsHandler* fsh = new Producer::FrameStatsHandler; - viewer->setStatsHandler(fsh); - viewer->getCamera(0)->addPostDrawCallback(fsh); - - if( !pathfile.empty() ) { osg::ref_ptr apm = new osgGA::AnimationPathManipulator(pathfile); if( apm.valid() && apm->valid() ) @@ -83,13 +75,6 @@ int main( int argc, char **argv ) // set the scene to render viewer->setSceneData(loadedModel.get()); - // set up the pthread stack size to large enough to run into problems. - viewer->setStackSize( 20*1024*1024); - - // add the stats event handler to handler keyboard events for - // setting set block on vsync, instrumentation etc. - viewer->getEventHandlerList().push_back(new StatsEventHandler(viewer)); - // create the windows and run the threads. viewer->realize(Producer::CameraGroup::ThreadPerCamera); diff --git a/src/Demos/osgproducer/threePipe.cfg b/src/Demos/osgproducer/threePipe.cfg deleted file mode 100644 index 3fd0e0d9a..000000000 --- a/src/Demos/osgproducer/threePipe.cfg +++ /dev/null @@ -1,83 +0,0 @@ -//#define SINGLE_PIPE -#define ASSYMETRICAL_FRUSTUM - - -Camera "Camera 1" -{ - RenderSurface "Window 1" - { -Visual { VisualID 0x172 }; -#ifdef SINGLE_PIPE - Screen 0; - WindowRectangle 0 0 426 512; -#else - Screen 2; -#endif - Border off; - }; - Lens { - Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0; - }; - Offset { -#ifdef ASSYMETRICAL_FRUSTUM - Shear 1.5 0.0; -#else - Rotate -90.0 1 0 0; - Rotate -45.0 0 0 1; - Rotate 90.0 1 0 0; -#endif - }; -} - -Camera "Camera 2" -{ - RenderSurface "Window 2" - { -Visual { VisualID 0x74 }; - Screen 0; -#ifdef SINGLE_PIPE - WindowRectangle 426 0 426 512; -#endif - Border off; - }; - Lens { - Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0; - }; -} - -Camera "Camera 3" -{ - RenderSurface "Window 3" - { -Visual { VisualID 0xF3 }; -#ifdef SINGLE_PIPE - Screen 0; - WindowRectangle 852 0 426 512; -#else - Screen 1; -#endif - Border off; - }; - Lens { - Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0; - }; - Offset { -#ifdef ASSYMETRICAL_FRUSTUM - Shear -1.5 0.0; -#else - Rotate -90.0 1 0 0; - Rotate 45.0 0 0 1; - Rotate 90.0 1 0 0; -#endif - }; -} - - -InputArea -{ - RenderSurface "Window 1" : -2.5 -0.5 -1.0 1.0; - RenderSurface "Window 2" : -1.0 1.0 -1.0 1.0; - RenderSurface "Window 3" : 0.5 2.5 -1.0 1.0; -} - - diff --git a/src/Demos/osgproducer/twoPipe.cfg b/src/Demos/osgproducer/twoPipe.cfg deleted file mode 100644 index bcf6b1338..000000000 --- a/src/Demos/osgproducer/twoPipe.cfg +++ /dev/null @@ -1,64 +0,0 @@ -/*#define SINGLE_PIPE */ -#define ASSYMETRICAL_FRUSTUM - -Camera "Camera 1" -{ - RenderSurface "Window 1" - { - Visual { SetSimple }; - Screen 0; -#ifdef SINGLE_PIPE - WindowRectangle 0 0 426 512; -#else -#endif - Border off; - }; - Lens { - Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0; - }; - Offset { -#ifdef ASSYMETRICAL_FRUSTUM - Shear 1.0 0.0; -#else - Rotate -90.0 1 0 0; - Rotate -22.5 0 0 1; - Rotate 90.0 1 0 0; -#endif - }; -} - -Camera "Camera 2" -{ - RenderSurface "Window 2" - { - Visual { SetSimple }; -#ifdef SINGLE_PIPE - Screen 0; - WindowRectangle 426 0 426 512; -#else - Screen 1; -#endif - Border off; - }; - Lens { - Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0; - }; - - Offset { -#ifdef ASSYMETRICAL_FRUSTUM - Shear -1.0 0.0; -#else - Rotate -90.0 1 0 0; - Rotate 22.5 0 0 1; - Rotate 90.0 1 0 0; -#endif - }; -} - -InputArea -{ - RenderSurface "Window 1" : -1.0 0.0 0.0 1.0; - RenderSurface "Window 2" : 0.0 1.0 0.0 1.0; -} - - diff --git a/src/Demos/osgproducer/twoWindows.cfg b/src/Demos/osgproducer/twoWindows.cfg deleted file mode 100644 index 76a96dd10..000000000 --- a/src/Demos/osgproducer/twoWindows.cfg +++ /dev/null @@ -1,36 +0,0 @@ - -Camera "Camera 1" -{ - RenderSurface "Pipe 0" - { - Visual { SetSimple }; - Screen 0; - Border off; - WindowRect 0 0 640 480; - }; - Lens { - Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0; - }; - Offset { - Shear 0.8 0.0; - }; -} - -Camera "Camera 2" -{ - RenderSurface "Pipe 1" - { - Visual { SetSimple }; - Screen 0; - Border off; - WindowRect 640 0 640 480; - }; - Lens { - Frustum -0.55228475 0.55228475 -0.41421356 0.41421356 1 1000.0; - }; - Offset { - Shear -0.8 0.0; - }; -} - - diff --git a/src/osgProducer/CameraGroup.cpp b/src/osgProducer/CameraGroup.cpp index 9eed83e22..7623cd9a6 100644 --- a/src/osgProducer/CameraGroup.cpp +++ b/src/osgProducer/CameraGroup.cpp @@ -3,9 +3,18 @@ //as published by the Free Software Foundation. #include +#include using namespace osgProducer; +std::string findCameraConfigFile(const std::string& configFile) +{ + std::string foundFile = osgDB::findDataFile(configFile); + if (foundFile.empty()) return ""; + else return foundFile; +} + + CameraGroup::CameraGroup() : Producer::CameraGroup() { _init(); @@ -16,7 +25,7 @@ CameraGroup::CameraGroup(Producer::CameraConfig *cfg): Producer::CameraGroup(cfg _init(); } -CameraGroup::CameraGroup(const std::string& configFile) : Producer::CameraGroup(configFile) +CameraGroup::CameraGroup(const std::string& configFile) : Producer::CameraGroup(findCameraConfigFile(configFile)) { _init(); } diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index a5aea169d..604f4dc02 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include @@ -103,6 +105,18 @@ void Viewer::setUpViewer(unsigned int options) _eventHandlerList.push_back(statesetManipulator.get()); } + if (options&STATS_MANIPULATOR) + { + // register the drawing of stats to pipe 0. + Producer::FrameStatsHandler* fsh = new Producer::FrameStatsHandler; + setStatsHandler(fsh); + getCamera(0)->addPostDrawCallback(fsh); + + // register the event handler for stats. + getEventHandlerList().push_back(new StatsEventHandler(this)); + + + } } unsigned int Viewer::addCameraManipulator(osgGA::CameraManipulator* cm)