From Terry Welsh, improved support for handling archives
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user