Home Game Development c++ – Singletons as presented in Game Engine Architecture by Jason Gregory

c++ – Singletons as presented in Game Engine Architecture by Jason Gregory

0
c++ – Singletons as presented in Game Engine Architecture by Jason Gregory

[ad_1]

I am reading the amazing Game Engine Architecture 3rd edition by Jason Gregory, but I have trouble understanding the singleton part, more particularly the part dealing with subsystem start/shutdown…

He presents a way to start and shutdown with a Singleton (Manager) not by implementing any constructor or destructor but using non-static methods startUp() and shutDown(). And he declares the instance manager as global before the main entry point. What I don’t understand is: is the manager are really a singleton? Because it’s not static and the constructor and destructor are not private…

Here is the implementation he gave for the renderManager:

class RenderManager
{
public:
 RenderManager()
 {
  // do nothing
 }
~RenderManager()
 {
 // do nothing
 }
 void startUp()
 {
 // start up the manager...
 }
 void shutDown()
{
// shut down the manager...
}

class PhysicsManager{ /* similar... */ };
class AnimationManager{ /* similar... */ };
class MemoryManager{ /* similar... */ };
class FileSystemManager { /* similar... */ };
// ...
RenderManager
PhysicsManager
AnimationManager
TextureManager
VideoManager
MemoryManager
FileSystemManager
// ...
gRenderManager;
gPhysicsManager;
gAnimationManager;
gTextureManager;
gVideoManager;
gMemoryManager;
gFileSystemManager;
int main(int argc, const char* argv)
{
// Start up engine systems in the correct order.
gMemoryManager.startUp();
gFileSystemManager.startUp();
gVideoManager.startUp();
gTextureManager.startUp();
gRenderManager.startUp();
gAnimationManager.startUp();
gPhysicsManager.startUp();
// ...
// Run the game.
gSimulationManager.run();
// Shut everything down, in reverse order.
// ...
gPhysicsManager.shutDown();
gAnimationManager.shutDown();
gRenderManager.shutDown();
gFileSystemManager.shutDown();
gMemoryManager.shutDown();

return 0;
}

My question is: does the startUp method call any static method to initialize/grab the an static instance of the manager?

[ad_2]