Add loading resource CFG to OgreMain?

What it says on the tin: a place to discuss proposed new features.
Post Reply
Posts: 397
Joined: Sat Nov 08, 2008 1:59 pm
x 2

Add loading resource CFG to OgreMain?

Post by JDX_John »

The Ogre sample code-base has this useful method, which I've seen copy-pasted in real apps:

Code: Select all

    /// Method which will define the source of resources (other than current folder)
    virtual void setupResources(void)
        // Load resource paths from config file
        ConfigFile cf;
        cf.load(mResourcePath + "resources_d.cfg");
		cf.load(mResourcePath + "resources.cfg");

        // Go through all sections & settings in the file
        ConfigFile::SectionIterator seci = cf.getSectionIterator();

        String secName, typeName, archName;
        while (seci.hasMoreElements())
            secName = seci.peekNextKey();
            ConfigFile::SettingsMultiMap *settings = seci.getNext();
            ConfigFile::SettingsMultiMap::iterator i;
            for (i = settings->begin(); i != settings->end(); ++i)
                typeName = i->first;
                archName = i->second;
                // OS X does not set the working directory relative to the app,
                // In order to make things portable on OS X we need to provide
                // the loading with it's own bundle path location
				if (!StringUtil::startsWith(archName, "/", false)) // only adjust relative dirs
					archName = String(macBundlePath() + "/" + archName);
                    archName, typeName, secName);

Is there a good reason why Ogre (maybe ResourceManager) doesn't have this built-in? Maybe to keep flexibility?

Post Reply