Sign in to follow this  
webjeff

organization

Recommended Posts

I have more an organization question about classes: I have a rendering class (IRender) lets say, I have objects (IAnimation, IModel) lets say, I have a ObjectManager (IObjectManager) who owns IRender, how should I pass that into the objects like this?: In IObjectManager: obj = new IModel(); obj->SetRender(IRender) ?? for each object? or: should I have a static in like a BaseObject, but then I still need someway to pass that in.? or: should the objects contain a static and create it and the Manager shouldn't know about it and only render objects, so it can't set states, do effects, etc. Any ideas on this? Jeff.

Share this post


Link to post
Share on other sites
I would probably do it the other way around:

// inside some IObject
void IObject::Render()
{
// Note: made IRender a singleton so that it can be easily accesed
// anywhere
IRender::GetInstance()->renderIObject(this);
}



So in this scenerio I have made IRender a singleton. I ussually make all managers singletons since there is really no reason to have more than one (always exceptions of course).

Now when ever an IObject wants to render itself it simple gets the static instance of the renderer, and passes itself to it.

With your IObjectManager all you need to do now is something like this:

for(every IObject in list)
{
m_ObjectList->render();
}



Hope that sparks some ideas for yah!
Matt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this