Jump to content
  • Advertisement
Sign in to follow this  
webjeff

organization

This topic is 4701 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 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!