Class StructureMy entire game engine was, at some level, contained within or managed by my Cb3dEngine class. My Engine class contained:
It seemed to be fine. My initialization could be extremely short, allowing me to develop DirectX applications very quickly. For instance, my initialization could have looked like this: InitSettings.UpdateFrame = MainLoop; //app-defined main loop InitSettings.KeyHandler = KeyHandler; //app-defined handler functions InitSettings.MouseHandler = MouseHandler; InitSettings.Hinst = hInst; InitSettings.Windowed = true; InitSettings.Width = 640; InitSettings.Height = 480; Cb3dEngine* g_pB3DEngine = new Cb3dEngine; g_pB3DEngine->Initialize(InitSettings); Cb3dViewportSet* MainSet = new Cb3dViewportSet(); g_pB3DEngine->SetViewportSet(MainSet); Cb3dMilkshapeMesh* msm = new Cb3dMilkshapeMesh("mesh.txt"); Cb3dMeshObject* msmObject = new Cb3dMeshObject(msm); msmObject->MyCoords.SetPosition(D3DXVECTOR3(0,0,220)); MainSet->ViewportByNumber(0)->AddObject(msmObject); D3DLIGHT8 Light; ZeroMemory((void*)&Light, sizeof(D3DLIGHT8)); Light.Type = D3DLIGHT_DIRECTIONAL; Light.Diffuse.r = Light.Diffuse.g = Light.Diffuse.b = 1.0f; Light.Specular.r = Light.Specular.g = Light.Specular.b = 1.0f; Light.Ambient.r = Light.Ambient.g = Light.Ambient.b = 0.3f; Light.Direction = D3DXVECTOR3(1,0,0); MainSet->ViewportByNumber(0)->AddLight(&Light); g_pB3DEngine->Run(); Just like that, I was up and running in a 640x480 windows DirectX application with a keyboard and a mouse and a Milkshape mesh all ready to go, lit by my one light. Everything was wonderful, except that somehow some of my objects were not getting destroyed during the execution of the program.
|