My current architecture for me game engine looks like this, though it is not accurate:
Everything graphics related is done in by GraphicsEngine
, and through its components, like Material
, Mesh
, etc). My problem is that I want to store the pointers in RenderData
, but I have to include the Mesh
, Material
etc header files, which have included glew
.
I currently change an objects material using GetRenderer().SetMaterial("xyz")
, which sets a string in the renderData
, to be processed by the graphics engine; then the correct pointer will be set, if it exists. This is not so modular, because the scene has graphics related files included, like glew
. This is a problem.
My only solution is to store indices in RenderData
. There wont be a material pointer, but instead, an index where the material is in the GraphicsEngine
s material store. This way, RenderData
is just a "blind" integer and string store, in which the Renderer egy the GraphicsEngine
works.
Is this a good solution?
Meshes have VertexData
members (position, normal, texture). When I call GraphicEngine.CreateMesh()
, passing the MeshName
and FileName
, where should the file processing go? I use Tiny Obj Loader, and I don't know where I should include it, and call its function.
I call the function from inside GraphicsEngine
, then I transform the returned structures to my Mesh's structure, which I pass to the Mesh's constructor. The initialised list will assign it to the corresponding member variable. Inside Mesh
, I pass the FileName
to the Mesh
constructor, and let it handle it all by itself. I think the first solution is better, but I don't really know why.
Maybe using GraphicsEngine
to "create" assets is better than GraphicsEngine
commanding assets to "be created"; but this is just a personal feeling. Which solution is better?