How to decouple data from rendering engine?

Started by
0 comments, last by swiftcoder 9 years, 12 months ago

Hi, I'm fairly new to C++ and graphics programmming and I'm having some troubles with how to decouple my data from other parts of the engine.

I got a Model class which holds all the data of my meshes, shaders, textures, vertex buffers and such. Also i have a graphics class which holds the device and context, and functions assosciated with them. Right now I pass the device and context to the Model class so that it can create the vertexbuffer and shaders; However I would prefer if my model class had no knowledge or dependancy on the device and context. I Guess i could move them to the graphics class and pass it the model, but that would just move the problem.

I have a root class that creates all the other components, input, audio, rendering, etc, would it be a good idea to put code that requires information from several parts here?

/Björn

Advertisement


I have a root class that creates all the other components, input, audio, rendering, etc, would it be a good idea to put code that requires information from several parts here?

If you take that approach, you'll end up with 90% of your codebase contained in you 'root class'. Not a good idea.

There is a real dependency between models and contexts - you need a context to allocate GPU resources. No point in hiding that dependency, it'll only complicate things.

Also worth noting that when people say you should decouple your data from code, this is probably not what they had in mind. Models are fundamentally a part of the renderer state, so coupling between those components is not a thin you should really be avoiding.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement