From 1e3b346a524c681a9457a2721dfd94c56199b6e5 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 12 Sep 2003 08:45:12 +0000 Subject: [PATCH] From Sebastien Kuntz, added support for external refernces to vertex/fragment program files. --- src/osgPlugins/osg/FragmentProgram.cpp | 19 +++++++++++++++++++ src/osgPlugins/osg/VertexProgram.cpp | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/osgPlugins/osg/FragmentProgram.cpp b/src/osgPlugins/osg/FragmentProgram.cpp index 97145ab26..46e83495e 100644 --- a/src/osgPlugins/osg/FragmentProgram.cpp +++ b/src/osgPlugins/osg/FragmentProgram.cpp @@ -45,6 +45,25 @@ bool FragmentProgram_readLocalData(Object& obj, Input& fr) } fragmentProgram.setFragmentProgram(code); } + + if( fr.matchSequence("file %s")) { + std::string filename = fr[1].getStr(); + fr += 2; + iteratorAdvanced = true; + + ifstream vfstream( filename.c_str() ); + + if( vfstream ) { + ostringstream vstream; + char ch; + + /* xxx better way to transfer a ifstream to a string?? */ + while( vfstream.get(ch)) vstream.put(ch); + + fragmentProgram.setFragmentProgram( vstream.str() ); + } + } + return iteratorAdvanced; } diff --git a/src/osgPlugins/osg/VertexProgram.cpp b/src/osgPlugins/osg/VertexProgram.cpp index 6c4695ca8..1f4487239 100644 --- a/src/osgPlugins/osg/VertexProgram.cpp +++ b/src/osgPlugins/osg/VertexProgram.cpp @@ -45,6 +45,26 @@ bool VertexProgram_readLocalData(Object& obj, Input& fr) } vertexProgram.setVertexProgram(code); } + + if( fr.matchSequence("file %s")) { + std::string filename = fr[1].getStr(); + + fr+=2; + iteratorAdvanced = true; + + ifstream vfstream( filename.c_str() ); + + if( vfstream ) { + ostringstream vstream; + char ch; + + /* xxx better way to transfer a ifstream to a string?? */ + while( vfstream.get(ch)) vstream.put(ch); + + vertexProgram.setVertexProgram( vstream.str() ); + } + } + return iteratorAdvanced; }