I am in the process of writing an entity component model game engine and I wanted to ask you a bit about the best way to lay out the code. I have run into an issue that I know will quickly cause me to run into more problems down the road. In short, I currently have a render component that I attach to the entity class. The problem is, I need the render component to signal the render engine and add its self to it.
I thought about creating a singleton for the render system, but I quickly realized that was a bad road and sooner or later I would be creating singletons for just about everything (Ex, physics for the physics component). What I am currently thinking of doing is creating the base Engine class as my only singleton. The engine class is responsible for initializing all of the systems available (such as the graphics and file systems), storing references to them, calling the game loop's update method, and keeping tract of all the entities in the game. If I did that, then my components or any other part of the code could easily reference the important systems they need to deal with via a simple Engine.MySystem. In the case of my render component, Engine.Graphics3D.addModel();.
Basically, what I am wondering is if this is an acceptable way of doing things or not. If not, could you suggest an approach that would be better? I could in theory pass a reference to the GFX system to the render component but that seems like a really bad idea. I feel like this is a nice middle ground between the two options.
Edit: Both of you have given me a lot to think about and I appreciate the help. I think I finally figured out a structure that will work. You both helped me in one way or another, so I am honestly not sure which answer to take.