From 8d0718e8dae46b99b12d09f33ed7f7767be8ad2d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 9 Dec 2002 21:03:02 +0000 Subject: [PATCH] Added setting of the current texture unit into the applyTextureAttribute() method. --- include/osg/State | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/include/osg/State b/include/osg/State index 282d6c34b..deec7f183 100644 --- a/include/osg/State +++ b/include/osg/State @@ -140,10 +140,15 @@ class SG_EXPORT State : public Referenced inline bool applyTextureMode(unsigned int unit, StateAttribute::GLMode mode,bool enabled) { - ModeMap& modeMap = getOrCreateTextureModeMap(unit); - ModeStack& ms = modeMap[mode]; - ms.changed = true; - return applyMode(mode,enabled,ms); + if (setActiveTextureUnit(unit)) + { + ModeMap& modeMap = getOrCreateTextureModeMap(unit); + ModeStack& ms = modeMap[mode]; + ms.changed = true; + return applyMode(mode,enabled,ms); + } + else + return false; } /** Apply an attribute if required. */ @@ -156,10 +161,15 @@ class SG_EXPORT State : public Referenced inline bool applyTextureAttribute(unsigned int unit, const StateAttribute* attribute) { - AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit); - AttributeStack& as = attributeMap[attribute->getType()]; - as.changed = true; - return applyAttribute(attribute,as); + if (setActiveTextureUnit(unit)) + { + AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit); + AttributeStack& as = attributeMap[attribute->getType()]; + as.changed = true; + return applyAttribute(attribute,as); + } + else + return false; } /** Mode has been set externally, update state to reflect this setting.*/