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.
This commit is contained in:
@@ -104,6 +104,20 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
|
||||
}
|
||||
};
|
||||
|
||||
class MyReadFileCallback : public osgDB::Registry::ReadFileCallback
|
||||
{
|
||||
public:
|
||||
virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& fileName, osgDB::Registry::CacheHintOptions useObjectCache)
|
||||
{
|
||||
std::cout<<"before readNode"<<std::endl;
|
||||
// note when calling the Registry to do the read you have to call readNodeImplementation NOT readNode, as this will
|
||||
// cause on infinite recusive loop.
|
||||
osgDB::ReaderWriter::ReadResult result = osgDB::Registry::instance()->readNodeImplementation(fileName,useObjectCache);
|
||||
std::cout<<"after readNode"<<std::endl;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
// use an ArgumentParser object to manage the program arguments.
|
||||
@@ -114,6 +128,9 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
|
||||
// set the osgDB::Registy the read file callback to catch all requests for reading files.
|
||||
osgDB::Registry::instance()->setReadFileCallback(new MyReadFileCallback());
|
||||
|
||||
// initialize the viewer.
|
||||
osgProducer::Viewer viewer(arguments);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user