Added support for setting the <image> 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.
This commit is contained in:
parent
c39ee015d6
commit
2faeaf553b
@ -21,6 +21,7 @@
|
||||
#include <osg/AnimationPath>
|
||||
#include <osg/TransferFunction>
|
||||
#include <osg/ImageStream>
|
||||
#include <osg/ImageSequence>
|
||||
#include <osgText/Text>
|
||||
#include <osgGA/GUIEventAdapter>
|
||||
|
||||
@ -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
|
||||
|
@ -879,6 +879,16 @@ bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::Slid
|
||||
OSG_NOTIFY(_notifyLevel)<<"read duration \""<<value.duration<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
if (getProperty(cur, "paging_mode", str))
|
||||
{
|
||||
propertiesRead = true;
|
||||
if (str=="PRE_LOAD_ALL_IMAGES") value.imageSequencePagingMode = osg::ImageSequence::PRE_LOAD_ALL_IMAGES;
|
||||
else if (str=="PAGE_AND_RETAIN_IMAGES") value.imageSequencePagingMode = osg::ImageSequence::PAGE_AND_RETAIN_IMAGES;
|
||||
else if (str=="PAGE_AND_DISCARD_USED_IMAGES") value.imageSequencePagingMode = osg::ImageSequence::PAGE_AND_DISCARD_USED_IMAGES;
|
||||
|
||||
OSG_NOTIFY(_notifyLevel)<<"read imageSequencePagingMode \""<<value.imageSequencePagingMode<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
if (getProperty(cur, "texcoord_offset", value.texcoord_offset))
|
||||
{
|
||||
|
@ -429,6 +429,10 @@ void SlideShowConstructor::addLayer(bool inheritPreviousLayers, bool defineAsBas
|
||||
{
|
||||
osg::Texture2D* texture = new osg::Texture2D(image.get());
|
||||
texture->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<osg::Image> 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<osg::ImageSequence> 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<<std::endl;
|
||||
osg::ref_ptr<osg::Image> 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<<std::endl;
|
||||
imageSequence->addImageFile(*itr);
|
||||
if (firstLoad)
|
||||
{
|
||||
osg::ref_ptr<osg::Image> 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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user