Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to decouple data from rendering engine?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 bjornp   Members   -  Reputation: 190

Like
0Likes
Like

Posted 21 April 2014 - 07:56 AM

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



Sponsor:

#2 swiftcoder   Senior Moderators   -  Reputation: 9993

Like
1Likes
Like

Posted 22 April 2014 - 04:01 AM


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 - Software Engineer @Amazon - [swiftcoding]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS