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?
architexture problems?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement