From 2faeaf553bab72d104674b83cf02323cc07f3a01 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 11 Jun 2012 19:54:07 +0000 Subject: [PATCH] Added support for setting the paging_mode property to PRE_LOAD_ALL_IMAGES, PAGE_AND_RETAIN_IMAGES or PAGE_AND_DICARD_IMAGE for osg::ImageStream, with PAGE_AND_DICARD_IMAGE set as the default. --- include/osgPresentation/SlideShowConstructor | 6 ++++- src/osgPlugins/p3d/ReaderWriterP3D.cpp | 10 ++++++++ src/osgPresentation/SlideShowConstructor.cpp | 25 ++++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/osgPresentation/SlideShowConstructor b/include/osgPresentation/SlideShowConstructor index 2469150e5..506524afe 100644 --- a/include/osgPresentation/SlideShowConstructor +++ b/include/osgPresentation/SlideShowConstructor @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -240,7 +241,9 @@ public: page(-1), backgroundColor(1.0f,1.0f,1.0f,1.0f), fps(30.0), - duration(-1.0) {} + duration(-1.0), + imageSequencePagingMode(osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES) + {} std::string options; float width; @@ -253,6 +256,7 @@ public: osg::Vec4 backgroundColor; double fps; double duration; + osg::ImageSequence::Mode imageSequencePagingMode; }; struct VolumeData diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index 7143bd9f0..bcea3a797 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -879,6 +879,16 @@ bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::Slid OSG_NOTIFY(_notifyLevel)<<"read duration \""<setResizeNonPowerOfTwoHint(false); + texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); + texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); + texture->setClientStorageHint(true); + backgroundStateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); @@ -820,6 +824,9 @@ osg::Geometry* SlideShowConstructor::createTexturedQuadGeometry(const osg::Vec3& texture = new osg::Texture2D(image); texture->setResizeNonPowerOfTwoHint(false); + texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); + texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); + texture->setClientStorageHint(true); stateset->setTextureAttributeAndModes(0, texture, @@ -854,7 +861,6 @@ osg::Image* SlideShowConstructor::readImage(const std::string& filename, const I osg::ref_ptr image; osgDB::DirectoryContents filenames; - bool preLoad = true; std::string foundFile = filename; @@ -923,11 +929,15 @@ osg::Image* SlideShowConstructor::readImage(const std::string& filename, const I osg::ref_ptr imageSequence = new osg::ImageSequence; + imageSequence->setMode(imageData.imageSequencePagingMode); + + bool firstLoad = true; + for(osgDB::DirectoryContents::iterator itr = filenames.begin(); itr != filenames.end(); ++itr) { - if (preLoad) + if (imageSequence->getMode()==osg::ImageSequence::PRE_LOAD_ALL_IMAGES) { OSG_INFO<<"Attempting to read "<<*itr< loadedImage = osgDB::readImageFile(*itr, options.get()); @@ -941,6 +951,15 @@ osg::Image* SlideShowConstructor::readImage(const std::string& filename, const I { OSG_INFO<<"Adding filename for load image on demand "<<*itr<addImageFile(*itr); + if (firstLoad) + { + osg::ref_ptr loadedImage = osgDB::readImageFile(*itr, options.get()); + if (loadedImage.valid()) + { + imageSequence->addImage(loadedImage.get()); + firstLoad = false; + } + } } } @@ -956,6 +975,8 @@ osg::Image* SlideShowConstructor::readImage(const std::string& filename, const I imageSequence->setLength(double(maxNum)*(1.0/imageData.fps)); } + imageSequence->play(); + image = imageSequence; }