diff --git a/src/Demos/osgtexture/osgtexture.cpp b/src/Demos/osgtexture/osgtexture.cpp index aaa480bb7..e10c0795d 100644 --- a/src/Demos/osgtexture/osgtexture.cpp +++ b/src/Demos/osgtexture/osgtexture.cpp @@ -23,6 +23,47 @@ typedef std::vector< osg::ref_ptr > ImageList; +class TextureCallback : public osg::NodeCallback +{ + public: + TextureCallback(osg::Texture* texture):_texture(texture) + { + _filterRange.push_back(osg::Texture::LINEAR); + _filterRange.push_back(osg::Texture::LINEAR_MIPMAP_LINEAR); + _filterRange.push_back(osg::Texture::LINEAR_MIPMAP_NEAREST); + _filterRange.push_back(osg::Texture::NEAREST); + _filterRange.push_back(osg::Texture::NEAREST_MIPMAP_LINEAR); + _filterRange.push_back(osg::Texture::NEAREST_MIPMAP_NEAREST); + _filterRange.push_back(osg::Texture::ANISOTROPIC); + _currPos = 0; + _prevTime = 0.0; + } + + virtual ~TextureCallback() {} + + virtual void operator()(osg::Node*, osg::NodeVisitor* nv) + { + if (nv->getFrameStamp()) + { + double currTime = nv->getFrameStamp()->getReferenceTime(); + if (currTime-_prevTime>1.0) + { + std::cout<<"Updating texturing filter to "<setFilter(osg::Texture::MAG_FILTER,_filterRange[_currPos]); + _currPos++; + if (_currPos>=_filterRange.size()) _currPos=0; + _prevTime = currTime; + } + } + } + + osg::ref_ptr _texture; + std::vector _filterRange; + osg::uint _currPos; + double _prevTime; +}; + + /** * Function to read several images files (typically one) as specified * on the command line, and return them in an ImageList @@ -134,6 +175,8 @@ osg::Node* createLayer(const osg::Vec3& offset,osg::Image* image,osg::Node* geom top_transform->addChild(createTexturedItem(local_offset,texture,geometry)); local_offset += local_delta; + + // top_transform->setAppCallback(new TextureCallback(texture)); }