Show
Ignore:
Timestamp:
04/10/04 18:11:56 (10 years ago)
Author:
robert
Message:

From Alberto Farre, changed the cache hint option in read*() calls from being
a bool to a enum osgDB::Registru::CacheHintOptions? to be used a bit mask flag.

From Robert Osfied, added osgDB::Registry::ReadFileCallback? and
osgDB::Registry::WriteFileCallback? to allow customizition of read and write
calls.

Files:
1 modified

Legend:

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

    r2517 r2877  
    105105}; 
    106106 
     107class MyReadFileCallback : public osgDB::Registry::ReadFileCallback 
     108{ 
     109public: 
     110    virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& fileName, osgDB::Registry::CacheHintOptions useObjectCache) 
     111    { 
     112        std::cout<<"before readNode"<<std::endl; 
     113        // note when calling the Registry to do the read you have to call readNodeImplementation NOT readNode, as this will 
     114        // cause on infinite recusive loop. 
     115        osgDB::ReaderWriter::ReadResult result = osgDB::Registry::instance()->readNodeImplementation(fileName,useObjectCache); 
     116        std::cout<<"after readNode"<<std::endl; 
     117        return result; 
     118    } 
     119}; 
     120 
    107121int main( int argc, char **argv ) 
    108122{ 
     
    114128    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    115129    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
     130    
     131   // set the osgDB::Registy the read file callback to catch all requests for reading files. 
     132   osgDB::Registry::instance()->setReadFileCallback(new MyReadFileCallback()); 
    116133    
    117134    // initialize the viewer.