Advertisement Jump to content
Sign in to follow this  
Bj

How to decouple data from rendering engine?

This topic is 1736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!