Show
Ignore:
Timestamp:
11/17/10 11:19:25 (3 years ago)
Author:
robert
Message:

Added texture pool handler to print out results from texture pool

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osganalysis/osganalysis.cpp

    r11864 r11918  
    2626#include <osgGA/TrackballManipulator> 
    2727#include <osgGA/StateSetManipulator> 
     28#include <osgGA/TrackballManipulator> 
     29#include <osgGA/FlightManipulator> 
     30#include <osgGA/DriveManipulator> 
     31#include <osgGA/KeySwitchMatrixManipulator> 
     32#include <osgGA/AnimationPathManipulator> 
     33#include <osgGA/TerrainManipulator> 
    2834 
    2935#include <osgUtil/IncrementalCompileOperation> 
     
    532538}; 
    533539 
     540class TexturePoolHandler : public osgGA::GUIEventHandler 
     541{ 
     542public: 
     543    virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) 
     544    { 
     545        if (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP) 
     546        { 
     547            if (ea.getKey()=='r') 
     548            { 
     549                osg::Texture::getTextureObjectManager(0)->reportStats(); 
     550            } 
     551        } 
     552        return false; 
     553    } 
     554}; 
     555 
    534556 
    535557int main(int argc, char** argv) 
     
    540562    osgViewer::Viewer viewer(arguments); 
    541563 
    542     viewer.setCameraManipulator( new osgGA::TrackballManipulator() ); 
    543     viewer.addEventHandler( new osgViewer::StatsHandler()); 
    544     viewer.addEventHandler( new osgViewer::WindowSizeHandler() ); 
    545     viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 
     564    // set up camera manipulators 
     565    { 
     566        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; 
     567 
     568        keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); 
     569        keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); 
     570        keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); 
     571        keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); 
     572 
     573        std::string pathfile; 
     574        char keyForAnimationPath = '8'; 
     575        while (arguments.read("-p",pathfile)) 
     576        { 
     577            osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); 
     578            if (apm || !apm->valid()) 
     579            { 
     580                unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 
     581                keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); 
     582                keyswitchManipulator->selectMatrixManipulator(num); 
     583                ++keyForAnimationPath; 
     584            } 
     585        } 
     586 
     587        viewer.setCameraManipulator( keyswitchManipulator.get() ); 
     588    } 
     589 
     590    // set up event handlers  
     591    { 
     592        viewer.addEventHandler( new osgViewer::StatsHandler()); 
     593        viewer.addEventHandler( new osgViewer::WindowSizeHandler() ); 
     594        viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 
     595        viewer.addEventHandler( new TexturePoolHandler() ); 
     596    } 
    546597 
    547598    /////////////////////////////////////////////////////////////////////////////////