diff --git a/include/osg/StateSet b/include/osg/StateSet index 84eba7c28..1ce25bf01 100644 --- a/include/osg/StateSet +++ b/include/osg/StateSet @@ -259,8 +259,10 @@ class OSG_EXPORT StateSet : public Object void setAssociatedModes(const StateAttribute* attribute, StateAttribute::GLModeValue value); + void removeAssociatedModes(const StateAttribute* attribute); void setAssociatedTextureModes(unsigned int unit,const StateAttribute* attribute, StateAttribute::GLModeValue value); + void removeAssociatedTextureModes(unsigned int unit,const StateAttribute* attribute); diff --git a/src/osg/StateSet.cpp b/src/osg/StateSet.cpp index 97f437c31..38e8ea4b1 100644 --- a/src/osg/StateSet.cpp +++ b/src/osg/StateSet.cpp @@ -1471,18 +1471,55 @@ class SetAssociateModesHelper : public StateAttribute::ModeUsage unsigned int _unit; }; +class RemoveAssociateModesHelper : public StateAttribute::ModeUsage +{ + public: + RemoveAssociateModesHelper(StateSet* stateset, unsigned int unit=0): + _stateset(stateset), + _unit(unit) {} + + virtual ~RemoveAssociateModesHelper() {} + + virtual void usesMode(StateAttribute::GLMode mode) + { + _stateset->removeMode(mode); + } + + virtual void usesTextureMode(StateAttribute::GLMode mode) + { + _stateset->removeTextureMode(_unit, mode); + } + + + + StateSet* _stateset; + unsigned int _unit; +}; + void StateSet::setAssociatedModes(const StateAttribute* attribute, StateAttribute::GLModeValue value) { SetAssociateModesHelper helper(this,value); attribute->getModeUsage(helper); } +void StateSet::removeAssociatedModes(const StateAttribute* attribute) +{ + RemoveAssociateModesHelper helper(this); + attribute->getModeUsage(helper); +} + void StateSet::setAssociatedTextureModes(unsigned int unit,const StateAttribute* attribute, StateAttribute::GLModeValue value) { SetAssociateModesHelper helper(this,value,unit); attribute->getModeUsage(helper); } +void StateSet::removeAssociatedTextureModes(unsigned int unit,const StateAttribute* attribute) +{ + RemoveAssociateModesHelper helper(this,unit); + attribute->getModeUsage(helper); +} + void StateSet::setAttribute(AttributeList& attributeList,StateAttribute *attribute, const StateAttribute::OverrideValue value) { if (attribute)