// ------------------------------------------------------- void Root::loadResourceConfig(const std::string &fileName) { Ogre::ConfigFile cf; cf.load(fileName); // Go through all sections & settings in the file const auto &settings = cf.getSettingsBySection(); Ogre::String secName, typeName, archName; for (const auto &sec : settings) { const Ogre::String &secName = sec.first; for (const auto &set : sec.second) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation( set.second, set.first, secName); } } }
void ApplicationContext::locateResources() { #if OGRE_PLATFORM == OGRE_PLATFORM_NACL Ogre::ResourceGroupManager::getSingleton().addResourceLocation("Essential.zip", "EmbeddedZip", "Essential"); Ogre::ResourceGroupManager::getSingleton().addResourceLocation("Popular.zip", "EmbeddedZip", "General"); #else // load resource paths from config file Ogre::ConfigFile cf; # if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID Ogre::ArchiveManager::getSingleton().addArchiveFactory( new Ogre::APKFileSystemArchiveFactory(mAAssetMgr) ); Ogre::ArchiveManager::getSingleton().addArchiveFactory( new Ogre::APKZipArchiveFactory(mAAssetMgr) ); cf.load(openAPKFile(mFSLayer->getConfigFilePath("resources.cfg"))); # else cf.load(mFSLayer->getConfigFilePath("resources.cfg")); # endif Ogre::String sec, type, arch; // go through all specified resource groups Ogre::ConfigFile::SettingsBySection_::const_iterator seci; for(seci = cf.getSettingsBySection().begin(); seci != cf.getSettingsBySection().end(); ++seci) { sec = seci->first; const Ogre::ConfigFile::SettingsMultiMap& settings = seci->second; Ogre::ConfigFile::SettingsMultiMap::const_iterator i; // go through all resource paths for (i = settings.begin(); i != settings.end(); i++) { type = i->first; arch = Ogre::FileSystemLayer::resolveBundlePath(i->second); Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec); } } sec = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME; const Ogre::ResourceGroupManager::LocationList genLocs = Ogre::ResourceGroupManager::getSingleton().getResourceLocationList(sec); OgreAssert(!genLocs.empty(), ("Resource Group '"+sec+"' must contain at least one entry").c_str()); arch = genLocs.front()->archive->getName(); #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE arch = Ogre::macBundlePath() + "/Contents/Resources/Media"; #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS arch = Ogre::macBundlePath() + "/Media"; #else arch = Ogre::StringUtil::replaceAll(arch, "Media/../../Tests/Media", ""); arch = Ogre::StringUtil::replaceAll(arch, "media/../../Tests/Media", ""); # endif type = genLocs.front()->archive->getType(); #ifdef OGRE_BUILD_PLUGIN_CG bool use_HLSL_Cg_shared = true; #else bool use_HLSL_Cg_shared = Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("hlsl"); #endif // Add locations for supported shader languages if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsles")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/GLSLES", type, sec); } else if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsl")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/GLSL120", type, sec); if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsl150")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/GLSL150", type, sec); } else { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/GLSL", type, sec); } if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsl400")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/GLSL400", type, sec); } } else if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("hlsl")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/HLSL", type, sec); } #ifdef OGRE_BUILD_PLUGIN_CG Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/Cg", type, sec); #endif if (use_HLSL_Cg_shared) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch + "/materials/programs/HLSL_Cg", type, sec); } #ifdef OGRE_BUILD_COMPONENT_RTSHADERSYSTEM mRTShaderLibPath = arch + "/RTShaderLib"; Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mRTShaderLibPath + "/materials", type, sec); if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsles")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mRTShaderLibPath + "/GLSL", type, sec); Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mRTShaderLibPath + "/GLSLES", type, sec); } else if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("glsl")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mRTShaderLibPath + "/GLSL", type, sec); } else if(Ogre::GpuProgramManager::getSingleton().isSyntaxSupported("hlsl")) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mRTShaderLibPath + "/HLSL", type, sec); } # ifdef OGRE_BUILD_PLUGIN_CG Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mRTShaderLibPath + "/Cg", type, sec); # endif if (use_HLSL_Cg_shared) { Ogre::ResourceGroupManager::getSingleton().addResourceLocation(mRTShaderLibPath + "/HLSL_Cg", type, sec); } #endif /* OGRE_BUILD_COMPONENT_RTSHADERSYSTEM */ #endif /* OGRE_PLATFORM == OGRE_PLATFORM_NACL */ }