From 67f31d948e54fc1f3e9b7d9895eb1a20f575fb38 Mon Sep 17 00:00:00 2001 From: Allofich Date: Wed, 10 Aug 2016 01:11:14 +0900 Subject: [PATCH] Add removeTexture method --- apps/openmw/mwrender/animation.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 4996ad2a82..77375b4106 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -269,10 +269,7 @@ namespace MWRender virtual void setDefaults(osg::StateSet *stateset) { if (mDone) - { - stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXTURE); - stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXGEN); - } + removeTexture(stateset); else { stateset->setTextureMode(mTexUnit, GL_TEXTURE_2D, osg::StateAttribute::ON); @@ -293,6 +290,19 @@ namespace MWRender } } + void removeTexture(osg::StateSet* stateset) + { + stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXTURE); + stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXGEN); + stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXENV); + stateset->removeTextureMode(mTexUnit, GL_TEXTURE_2D); + stateset->removeUniform("envMapColor"); + + osg::StateSet::TextureAttributeList& list = stateset->getTextureAttributeList(); + while (list.size() && list.rbegin()->empty()) + list.pop_back(); + } + virtual void apply(osg::StateSet *stateset, osg::NodeVisitor *nv) { if (mColorChanged){ @@ -315,7 +325,7 @@ namespace MWRender { if (mOriginalDuration >= 0) // if this glowupdater was a temporary glow since its creation { - stateset->removeTextureAttribute(mTexUnit, osg::StateAttribute::TEXTURE); + removeTexture(stateset); this->reset(); mDone = true; mResourceSystem->getSceneManager()->recreateShaders(mNode);