ambakshi
4/18/2011 - 11:07 PM

Explicit initialization and dependencies of subsystems.

Explicit initialization and dependencies of subsystems.

int main(int argc, const char** argv) {

   int flags = FlagsFromArgs(argc, argv);

   Memory* memory = MemoryNew( MEMORY_HEAP_256MB | MEMORY_HEAP_DEBUG | flags );
   Sound* sound = SoundNew( memory, SOUNDMGR_ALL_CHANELS | flags );
   Renderer* renderer = RendererNew( memory, RENDERER_TRIPLE_BUFFER | RENDERER_SM_20 | flags );
   Physics* phys = PhysicsNew( memory, sound, PHYSICS_AWESOME_FLAG | flags);
   // .. etc ..
   Game* game = GameNew( memory, sound, physics, ... , GAME_AAA_MODE | flags );

   while(GameRunning(game)) {
     // ...
   };

   int rc = GameDelete(game);
   PhysicsDelete(phys);
   RendererDelete(renderer);
   SoundDelete(sound);
   MemoryDelete(memory);

   return rc;
};