Skip to main content

History: Ogre Internals Dissection FAQ

Source of version: 3

Copy to clipboard
            
    1.  Root - the obligatory class/ object.
    1a. Why do I have to allocate root on heap, and not on stack ?
    1b. How to create similar class with getSingleton() method ?
    1b2. I need more than one window for my app, can I create more than one root
    object for that purpose ?
    1b3. Can I run  Ogre3d without actually initializing root ? What functions I do have at hand then ?
    1c. Ogre::Root::initialise fails -- the most common causes.
    1d. Explicit 'delete root' causes application crash.
    1d2.Explicit 'root->shutdown()' causes application crash.
    1d3.Ways of properly shouting down the Ogre3d without leaking the resources.
    1e. Ogre::Root extra parametes
    1e2. Example Window without borders.
    1f. root->showConfigDialog displays an empty window.
   
     RESOURCES, MATERIALS, AND RESOURCES' MANAGMENT
     
    2a. Do I need to use the Resource, ResouceManagers schemes ?
    2a2. Can I make my game without this mechanism ?
    2b. Why does my object display as white (or black) in Ogre?
    2b2. Why does my resource creation or load fail in strange ways?
    2b3. What is the Ogre::Resource's typical lifecycle ( diagram or scheme ) ?
    2b4. What are usual methods of managing this lifecycle ?
    2b5. Why is OgreCore.zip missing?
     
    2c. Why it only service small part of assets' types needed to create game (e.g. no music , sound files , no third party data ) .
    2c2. How do I extend that mechanism for all assets in my game ?
    2c3. How do I write my own Resource type ?
    2c4. How do I write my own Resource manager ?{TOC}
  
     
    answers :
    1.  ROOT - THE OBLIGATORY CLASS/ OBJECT.
     
     
     
    1a. Why do I have to allocate root on heap, and not on stack ?
    That is why I do have to write
     
        Root *root = new Root();
     
    and not just :
     
        Root root = Root();
     
    ?
    A:
    Well, devel sindbad often holds root inside a manager class so Root gets constructed as soon as the manager is. So it actually becomes:
     
     
     
        class SomeManager
        {
        protected:
            Ogre::Root mOgreRoot;
        ...
        }
     
     
     
    You might construct Root like that in your entry point Before the frame loop
    is kicked off. When using RAII technique ( that is what this snippet does )
    you must just guard that out mOgreRoot won't be poped off from stack while the
    app is running. This is hard to do with RAII, as with that the function
    call frames are deleted in reversed order they were put onto the stack -- that
    is the 'newest ' call frame first, but when using say threading the things
    get more complicated... ( note : This is actually the same consideration as making sure you
    don't call 'delete mOgreeRootPointer' during the program main loop.)
     
     
     
    Thus there really isn't a concrete need to manage Root using new/delete, although you can if you want.
     
    1b. How to create similar class with getSingleton() method ?
     
    This pattern is called Singleton :
    http://en.wikipedia.org/wiki/Singleton_pattern
     
    Deriving from Ogre::Singleton is merely a matter of doing this:
     
        MyAwesomeClass :: public Ogre::Singleton<MyAwesomeClass>
        {
        //code omitted - obviously
        };
     
    And in the implementation file:
     
        template<> MyAwesomeClass* Ogre::Singleton<MyAwesomeClass>::ms_Singleton = 0;
     
    The Ogre3d's Singleton has been written by Scott Bilas, here's his blog entry
    discussing similar Singleton variant :
    http://scottbilas.com/publications/gem-singleton/ .
     
     
    1b2. I need more than one window for my app, can I create more than one root
    object for that purpose ?
     
    Two instances of root  is not possible/recommend/supported.
    (M)Ogre uses Singletons, that is one instance of the object in the same
    application context) e.g. TextureManager, MeshManager and of course
    Ogre::Root, creating  -> the second created root will "override" the first one.
     
     
    1b3. Can I run  Ogre3d without actually initializing root ? What functions I
    do have at hand then ?
     
    1b4. But I have read the tutorial and source SDK , the root is created nowhere
    !!!!
     
    Most of the tutorials use the ExampleApplication framework, which does a lot of behind-the-scenes stuff, including the creation of the root.
     
    1c. Ogre::Root::initialise fails -- the most common causes.
     
    1d. Explicit 'delete root' causes application crash.
     
    The most possible cause is : your application must have had deleted root
    explictly or implicitly before your 'delete root' .
     
    1d2. Explicit 'root->shutdown()' causes application crash.
     
    1d3.Ways of properly shouting down the Ogre3d without leaking the resources.
     
    1e. Ogre::Root extra parametes
     
    1e2. Example Window without borders.
     
     
    First assign a value of "none" to misc["Border"]
    Next, make sure that when you initialise Ogre, you tell it NOT to create a default window. (pass false as the first param)
    Then, create a render window, and assign it to the "window" member variable of your application.
     
        // create some custom attributes for our manually created window
     
        Ogre::NameValuePairList misc;
        misc["border"] = "none";
        misc["monitorIndex"] = "0";  //I use two monitors, so I tell Ogre to draw on my main (#1) monitor
     
        // Here we tell the system not to create a default rendering window by passing 'false'
     
        mWindow = mRoot->initialise(false, "BasicTutorial7 Render Window");
     
        //now we need to create a render window manually
        //for now, the dimensions are hardcoded to MY desktop size so the window LOOKS full screen
     
        mWindow = mRoot->createRenderWindow("BasicTutorial7 Render Window",1680,1050,false, &misc ); //pass our custom attributes in "misc"
     
    1f. root->showConfigDialog displays an empty window.
     
     RESOURCES, MATERIALS, AND RESOURCES' MANAGMENT
     
    2a. Do I need to use the Resource, ResouceManagers schemes ?
    2a2. Can I make my game without this mechanism ?
     
    2b. Why does my object display as white (or black) in Ogre?
    2b2. Why does my resource creation or load fail in strange ways?
    2b3. What is the Ogre::Resource's typical lifecycle ( diagram or scheme ) ?
    2b4. What are usual methods of managing this lifecycle ?
    2b5. Why is OgreCore.zip missing?
     
    2c. Why it only service small part of assets' types needed to create game (e.g. no music , sound files , no third party data ) .
    2c2. How do I extend that mechanism for all assets in my game ?
    2c3. How do I write my own Resource type ?
    2c4. How do I write my own Resource manager ?


        

History

Information Version
Sun 02 of Apr, 2017 14:45 GMT-0000 paul424 118
Sun 02 of Apr, 2017 14:44 GMT-0000 paul424 117
Tue 28 of Oct, 2014 11:31 GMT-0000 paul424 116
Sat 25 of Oct, 2014 17:45 GMT-0000 paul424 115
Fri 24 of Oct, 2014 18:06 GMT-0000 paul424 114
Fri 24 of Oct, 2014 17:59 GMT-0000 paul424 113
Fri 24 of Oct, 2014 17:58 GMT-0000 paul424 112
Fri 24 of Oct, 2014 17:56 GMT-0000 paul424 111
Tue 21 of Oct, 2014 15:44 GMT-0000 paul424 110
Mon 20 of Oct, 2014 20:01 GMT-0000 paul424 109
Fri 17 of Oct, 2014 22:08 GMT-0000 paul424 108
Fri 17 of Oct, 2014 22:07 GMT-0000 paul424 107
Fri 17 of Oct, 2014 22:03 GMT-0000 paul424 106
Fri 17 of Oct, 2014 22:01 GMT-0000 paul424 105
Fri 17 of Oct, 2014 21:57 GMT-0000 paul424 104
Fri 17 of Oct, 2014 21:51 GMT-0000 paul424 103
Fri 17 of Oct, 2014 21:48 GMT-0000 paul424 102
Fri 17 of Oct, 2014 21:45 GMT-0000 paul424 101
Fri 17 of Oct, 2014 21:43 GMT-0000 paul424 100
Mon 13 of Oct, 2014 13:36 GMT-0000 paul424 99
Mon 13 of Oct, 2014 13:36 GMT-0000 paul424 98
Mon 13 of Oct, 2014 13:35 GMT-0000 paul424 97
Mon 13 of Oct, 2014 13:33 GMT-0000 paul424 96
Mon 13 of Oct, 2014 13:32 GMT-0000 paul424 95
Mon 13 of Oct, 2014 13:31 GMT-0000 paul424 94