Im trying to create a single class that contains a container, with which holds pointers to a bunch of effect objects, such as
Manager Effects;
LightEffect* TwoLight = new LightEffect();
Effects.add(TwoLight);
Where, the manager class contains , a container of type
std::vector<effect*>FX_List;
and where effect is an effect class, with common variables, that all other effects derive from to customize themselves
class effect{
//common attributes
};
class TwoLight : public effect{
}
class InfrRedLight : public effect{
}
class Blur: public effect{
}
class Drunk: public effect{
}
now effects render and build effect etc methods will be virtual, so that each derived class implements them, themselves. But im wondering a few things.
1. How to actually access the manager?
The only ways i can think of is one of these 3
Effects->FX_List[4]->render() //which is an waful way
the other way is with an enum, but this requires the effects to be pushed back in order of the enum, which isnt great
enum effects { effect1 = 0, blur, drunken, weird};
Effects->FX_List[effect]->render();
and finally this way
Effects->add(blurEffect);
int blur = Effects->FX_List.size() - 1;
Effects->FX_List[blur]->render();
all of which still need wrapping up in nicer methods, but im still thinking there could be a better way.
And the other question, is how to set up each effect before rendering, when you only have access to the EffectManager. With the vector containing a list of the base type pointer, and made virtual, i can correctly call the derived render() and build() methods, but i can't access the members that are defined in the derived classes, as i only have a base pointer, unless i cast them of course, but this is still a little awkward.
any advice?