Using the previously applied code we are now going to create a class to separate the Ogre code from the main function.
Create the class
MyApplication
, which has two private pointers, one to a Ogre 3DSceneManager
and the other to theRoot
class:class MyApplication { private: Ogre::SceneManager* _sceneManager; Ogre::Root* _root;
The rest of this class should be public:
public:
Create a
loadResources()
function, which loads theresources.cfg
configuration file:void loadResources() { Ogre::ConfigFile cf; cf.load(«resources_d.cfg»);
Iterate over the sections of the configuration file:
Ogre::ConfigFile::SectionIterator sectionIter = cf.getSectionIterator(); Ogre::String sectionName, typeName, dataname; while (sectionIter.hasMoreElements()) {
Get the section name and the iterator for the settings:
sectionName = sectionIter.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = sectionIter.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i;
Iterate...