Time for action — creating a class

Using the previously applied code we are now going to create a class to separate the Ogre code from the main function.

  1. Create the class MyApplication, which has two private pointers, one to a Ogre 3D SceneManager and the other to the Root class:
    class MyApplication
    {
    private:
    Ogre::SceneManager* _sceneManager;
    Ogre::Root* _root;
    
  2. The rest of this class should be public:
    public:
    
  3. Create a loadResources() function, which loads the resources.cfg configuration file:
    void loadResources()
    {
    Ogre::ConfigFile cf;
    cf.load(«resources_d.cfg»);
    
  4. Iterate over the sections of the configuration file:
    Ogre::ConfigFile::SectionIterator sectionIter = cf.getSectionIterator(); Ogre::String sectionName, typeName, dataname; while (sectionIter.hasMoreElements()) ...

Get Ogre 3D 1.7 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.