tl;dr: Trying to figure out how DI works (caused large parameter list) and if it's a good alternative to singletons.
I have a few subsystem or manager type classes which will most likely be one instance and perhaps this is dumb, but I wanna try avoiding singletons (although that's probably the easiest) and I might be wrong, but dependency injection seems to be an alterative. To my understanding instead of having an object accessible anywhere all the time you just pass the instance where needed.
I don't believe I've used DI properly though all I seem to have done is bloat the parameter list for my constructor.
// main function
inputManager = new InputManager();
toolOverlay = new ToolOverlay();
meshManager = new MeshManager();
shaderManager = new ShaderManager();
ui = new UI(rmlContext);
scene = new Scene();
game = new Game(*inputManager, *meshManager, *shaderManager, *ui, *scene);
// game.cpp
Game::Game(InputManager& inputManager, MeshManager& meshManager, ShaderManager& shaderManager, UI& ui, Scene& scene) :
inputManager(inputManager),
meshManager(meshManager),
shaderManager(shaderManager),
uiManager(ui),
scene(scene)
{
AssetHandle suzanne = meshManager.loadMesh("Assets/Meshes/suzanne.obj");
AssetHandle basic = shaderManager.loadShader("Assets/Shaders/Mesh.vert", "Assets/Shaders/Mesh.frag");
player = std::make_unique<Player>(suzanne, basic);
camera = std::make_unique<Camera>(inputManager);
}
For some more context Game originally initialized everything until the thought occurred to me that some things were more engine related and should probably start before the game since the game is what uses it so I moved everything into the main function and attempted to do DI.