Added support for an externally referenced shader file, via the keyword combinations
file "shader.vert" OR file shader.vert.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
#include "osg/Shader"
|
||||
#include "osg/Notify"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "osgDB/Registry"
|
||||
#include "osgDB/Input"
|
||||
#include "osgDB/Output"
|
||||
#include "osgDB/FileUtils"
|
||||
|
||||
using namespace osg;
|
||||
using namespace osgDB;
|
||||
@@ -37,6 +40,22 @@ bool Shader_readLocalData(Object& obj, Input& fr)
|
||||
fr+=2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
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() );
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Warning: could not find shader file \""<<fr[1].getStr()<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
if (fr.matchSequence("code {"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user