From 9e92b9b89919a3b63ffed9fada922ada9058b0dd Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 14 Mar 2002 16:42:43 +0000 Subject: [PATCH] Added a TextureCallback which cycles through various filter modes, used in testing new glTextParamters update functionality. I have commented out the call to attaching of the callback so osgtexture outwardly behaves as before. The code lies dormant just incase we need to use it for testing in the future. --- src/Demos/osgtexture/osgtexture.cpp | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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)); }