Taken a closer look now and it's still a little bit confusing.
It's already past 0 am here and I'm a little bit sleepy but just wanted to finish this while watching TV. So I'm sorry if I misinterpreted anything.
-----
The calling path is a little bit like this (looking at constructor calls only):
Code: Select all
main()
+- CGame Game()
+- CGamePlay m_GamePlay()
+- CGameState m_GameState()
+- CGamePlayBoot m_GamePlayBoot()
+-CGameManager m_GameManager()
+- CGameManager m_GameManager()
Now the main loop:
Code: Select all
main()
+- Game.Run()
+- while
+- m_GamePlay.Continue (while condition)
+- m_GamePlay.Update()
+- mGameManager.m_pDriver->beginScene()
+- mGameManager.m_pSmgr->drawAll()
+- mGameManager.m_Gui->drawAll()
+- m_GameState.CurrentState()
+- m_GamePlayBoot.CreateDevice()
+- m_GameManager.m_pDevice = createDevice(...) [!]
+- m_GameManager.m_pDriver = ... [!]
+- m_GameManager.m_pDriver->endScene()
Look at the lines marked with "[!]". They do something with the CGameManager object but it isn't the one used by the CGamePlay class (it would have to be on the same level).
Also if I'm seeing this right, your main loop will try to render the scene before setting up the device, driver, etc. That's one of the reasons the code won't work. Also CreateDevice (CGamePlayBoot class) won't work with CGamePlay's GameManager so it will never be able to display anything.
-----
I've seen that you use variables to store your own objects (your classes). This has one big disadvantage: Every place you create such a variable it will keep its own copy of the object.
Just a short example code:
Code: Select all
class B; // content is trivial, just to show you ...
class A {
B myobject1;
B myobject2;
A()
{
myobject1=myobject2=B();
}
}
If you now create an object of class A its members myobject1/2 will each contain one independent object of class B. If you change myobject1 it won't change myobject2. This is the same for variables used in different classes (like your m_GameManagers).
A solution to this are pointers like you used for the Irrlicht classes. But important: Declaring variables using the same name within different classes won't mean that they share the same content.
Code: Select all
class B;
B* myobject1;
B* myobject2;
myobject1=myobject2=new B();
After those lines myobject1 as well as myobject2 will point to the same object/memory area. Don't forget that you'll have to delete objects created using the new operator. An alternative would be using a reference counter class like Irrlicht's IReferenceCounted.
A hint (not meant as an offence or anything similar): Start a new simple project and play a little bit with classes, objects and pointers. Try to create some simple class (maybe a custom vector class that allows you to call methods like GetLength()) and create it, destroy it, try to base it on IReferenceCounted, etc. just to get used to it. Then after you've done this, continue working on your game engine. This should save you a lot of trouble and time as well.
If you want, take a look here:
http://www.cplusplus.com/doc/tutorial/pointers.html