Ember

setupResources()

Aug 16th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.02 KB | None | 0 0
  1. //-------------------------------------------------------------------------------------
  2. bool Ogre3D::setupResources(void)
  3. {
  4.     // Add important resource paths
  5.     Ogre::ResourceGroupManager::getSingleton().addResourceLocation("./Resources/SdkTrays.zip", "Zip", "Essential");
  6.     Ogre::ResourceGroupManager::getSingleton().addResourceLocation("./Resources/Shaders", "FileSystem", "Essential");
  7.  
  8.     // Add non-important resource paths
  9.     Ogre::ResourceGroupManager::getSingleton().addResourceLocation("./Resources/Female", "FileSystem", "General");
  10.  
  11.     // A list of required plugins
  12.     Ogre::StringVector required_plugins;
  13.     required_plugins.push_back("Direct3D9 Rendering Subsystem");
  14.     required_plugins.push_back("Cg Program Manager");
  15.  
  16.     // List of plugins to load
  17.     Ogre::StringVector plugins_toLoad;
  18.     plugins_toLoad.push_back("Direct3D9");
  19.     plugins_toLoad.push_back("CgProgramManager");
  20.  
  21.     // Import plugins
  22.     for(Ogre::StringVector::iterator j = plugins_toLoad.begin(); j != plugins_toLoad.end(); j++)
  23.     {
  24.         mRoot->loadPlugin(*j);
  25.     }
  26.  
  27.     // Return if the number of loaded plugins is equal to plugins to load, if not, exit the application
  28.     Ogre::Root::PluginInstanceList ip = mRoot->getInstalledPlugins();
  29.  
  30.     // Check if the required plugins are installed and ready for use
  31.     // If not: exit the application
  32.     Ogre::Root::PluginInstanceList ip = mRoot->getInstalledPlugins();
  33.     for (Ogre::StringVector::iterator j = required_plugins.begin(); j != required_plugins.end(); j++)
  34.     {
  35.         bool found = false;
  36.         // try to find the required plugin in the current installed plugins
  37.         for(Ogre::Root::PluginInstanceList::iterator k = ip.begin(); k != ip.end(); k++)
  38.         {
  39.             if ((*k)->getName() == *j)
  40.             {
  41.                 found = true;
  42.                 break;
  43.             }
  44.         }
  45.         if (!found)  // return false because a required plugin is not available
  46.         {
  47.             return false;
  48.         }
  49.     }
  50.  
  51.     return true;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment