An abstract base class that can be extended to support custom material auto bindings. More...
Public Member Functions | |
virtual | ~AutoBindingResolver () |
Destructor. | |
virtual bool | resolveAutoBinding (GLProgramState *glProgramState, Node *node, const std::string &uniformName, const std::string &autoBinding)=0 |
Called when an unrecognized uniform variable is encountered during material loading. More... | |
An abstract base class that can be extended to support custom material auto bindings.
Implementing a custom auto binding resolver allows the set of built-in parameter auto bindings to be extended or overridden. Any parameter auto binding that is set on a material will be forwarded to any custom auto binding resolvers, in the order in which they are registered. If a registered resolver returns true (specifying that it handles the specified autoBinding), no further code will be executed for that autoBinding. This allows auto binding resolvers to not only implement new/custom binding strings, but it also lets them override existing/built-in ones. For this reason, you should ensure that you ONLY return true if you explicitly handle a custom auto binding; return false otherwise.
Note that the custom resolver is called only once for a GLProgramState object when its node binding is initially set. This occurs when a material is initially bound to a Node. The resolver is NOT called each frame or each time the GLProgramState is bound.
If no registered resolvers explicitly handle an auto binding, the binding will attempt to be resolved using the internal/built-in resolver, which is able to handle any auto bindings found in the GLProgramState::AutoBinding enumeration.
When an instance of a class that extends AutoBindingResolver is created, it is automatically registered as a custom auto binding handler. Likewise, it is automatically unregistered on destruction.
|
pure virtual |
Called when an unrecognized uniform variable is encountered during material loading.
Implementations of this method should do a string comparison on the passed in name parameter and decide whether or not they should handle the parameter. If the parameter is not handled, false should be returned so that other auto binding resolvers get a chance to handle the parameter. Otherwise, the parameter should be set or bound and true should be returned. The glProgramState The node that the material is attached to. Name of the uniform Name of the auto binding to be resolved. True if the auto binding is handled and the associated parameter is bound, false otherwise.