文件I/O
命名规则
osgdb_xxx
比如:
osgdb_osg
osgdb_jpeg
关联文件后缀和加载器
osgDB::Registry::instance()->addFileExtensionAlias( "jpeg", "jpeg" );
osgDB::Registry::instance()->addFileExtensionAlias( "jpg", "jpeg" );
使用
osg::Node* node = osgDB::readNodeFile( "cow.osg" );
osg::Image* image = osgDB::readImageFile( "Images/lz.rgb" );
说明
加载文件两个步骤
- osgDB::Registry
- 单一实例
- 管理着常用文件I/O插件列表
- 逐一向下传递
- 外部共享模块
已支持
伪加载
并非实际的文件后缀
自定义加载
osgDB::ReaderWriter
-
supportsExtension
-
acceptsExtension
-
fileExists
-
readNode
osgDB::ReaderWriter::ReadResult readNode(const std::string& file,const osgDB::Options* options) const { // Check if the file extension is recognizable and file exists bool recognizableExtension = …; bool fileExists = …