From Terry Welsh, improved support for handling archives

This commit is contained in:
Robert Osfield
2012-02-03 11:09:45 +00:00
parent fe61dcac69
commit 1ed3833556
2 changed files with 15 additions and 8 deletions

View File

@@ -69,6 +69,15 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter
return new osg::Shader( shader->getType(), code );
}
virtual ReadResult readObject(std::istream& fin,const Options* options) const
{
return readShader(fin, options);
}
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
{
return readShader(file, options);
}
virtual ReadResult readShader(std::istream& fin,const Options* options) const
{

View File

@@ -8,6 +8,7 @@
#include "osgDB/Input"
#include "osgDB/Output"
#include "osgDB/FileUtils"
#include "osgDB/ReadFile"
#include "osgDB/WriteFile"
using namespace osg;
@@ -44,15 +45,12 @@ bool Shader_readLocalData(Object& obj, Input& fr)
if (fr.matchSequence("file %w") || fr.matchSequence("file %s") )
{
std::string fileName = osgDB::findDataFile(fr[1].getStr());
if (!fileName.empty())
{
shader.loadShaderSourceFromFile( fileName.c_str() );
}
osg::ref_ptr<Shader> s = osgDB::readShaderFile(fr[1].getStr(), fr.getOptions());
if(s.get())
shader.setShaderSource(s->getShaderSource());
else
{
osg::notify(osg::NOTICE)<<"Warning: could not find shader file \""<<fr[1].getStr()<<"\""<<std::endl;
}
shader.loadShaderSourceFromFile( osgDB::findDataFile(fr[1].getStr()) );
fr += 2;
iteratorAdvanced = true;