Jump to content
  • Advertisement
Sign in to follow this  
thedodgeruk

architexture problems?

This topic is 2439 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

i have an architexture problem , and cant seam to get my head around it



i have a render class, in it is basic funtions, like collectLights etc;

i have classes wheich are not inherited but included in it , and they are called in order ie , renderModels, renderBillboards

so its all split up into groups, but i need theses claasses to be able to acces the render class.
cant do it with inheritence , so how do i allow these classes to call funtions and use funtions from the render class?

Share this post


Link to post
Share on other sites
Advertisement
Somewhere out there a baby dictionary just committed suicide.



You really have 3 routes.

1- pass the renderer reference in as a parameter at some point, probably on construction
2- use inheritance where some base class has access to the renderer or as a friend, or your renderer takes a common base class of items to render.
3- make the renderer globally available in some form, either as a global, a singleton or some other mechanism.



Number 1 is probably the most commonly implemented, in that classes that need access to the renderer are passed a reference on construction or via an Init() type call, while 3 is hands down the easiest.

Myself, I would probably engineer my code so that it was a black box that was passed into a renderer. In theory the renderer should be as decoupled as possible as it is the most probable code to actually require replacing in the future ( for example to support a different platform or library ). I would accomplish this by inheriting a base Renderable interface, which I suppose would mean I would choose 2.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!