From b5f86d99846629168a8fb5af4f0e6fe4280875f2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 21 Dec 2005 10:32:48 +0000 Subject: [PATCH] Added support for an externally referenced shader file, via the keyword combinations file "shader.vert" OR file shader.vert. --- src/osgPlugins/osg/Shader.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/osgPlugins/osg/Shader.cpp b/src/osgPlugins/osg/Shader.cpp index fd7291396..11de40d97 100644 --- a/src/osgPlugins/osg/Shader.cpp +++ b/src/osgPlugins/osg/Shader.cpp @@ -1,10 +1,13 @@ #include "osg/Shader" +#include "osg/Notify" #include #include + #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 \""<