From 91af37573a99142bf5db5e7503c8a238deea9b96 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 8 Nov 2004 17:12:36 +0000 Subject: [PATCH] Added public access to VertexProgram's LocalParamters and added .osg support for these. --- include/osg/VertexProgram | 10 +++++++++- src/osgPlugins/osg/VertexProgram.cpp | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/osg/VertexProgram b/include/osg/VertexProgram index 9e1e60425..4c19ffdee 100644 --- a/include/osg/VertexProgram +++ b/include/osg/VertexProgram @@ -172,6 +172,15 @@ class SG_EXPORT VertexProgram : public StateAttribute _programLocalParameters[index] = p; } + typedef std::map LocalParamList; + + /** Get list of Program Parameters */ + inline LocalParamList& getLocalParamList() { return _programLocalParameters; } + + /** Get const list of Program Parameters */ + inline const LocalParamList& getLocalParamList() const { return _programLocalParameters; } + + /** Set matrix. */ inline void setMatrix(const GLenum mode, const Matrix& matrix) { @@ -267,7 +276,6 @@ class SG_EXPORT VertexProgram : public StateAttribute std::string _vertexProgram; - typedef std::map LocalParamList; LocalParamList _programLocalParameters; typedef std::map MatrixList; diff --git a/src/osgPlugins/osg/VertexProgram.cpp b/src/osgPlugins/osg/VertexProgram.cpp index c3d64f450..8090bf834 100644 --- a/src/osgPlugins/osg/VertexProgram.cpp +++ b/src/osgPlugins/osg/VertexProgram.cpp @@ -31,6 +31,20 @@ bool VertexProgram_readLocalData(Object& obj, Input& fr) VertexProgram& vertexProgram = static_cast(obj); + if (fr[0].matchWord("ProgramLocalParameter")) + { + int index; + Vec4 vec; + fr[1].getInt(index); + fr[2].getFloat(vec[0]); + fr[3].getFloat(vec[1]); + fr[4].getFloat(vec[2]); + fr[5].getFloat(vec[3]); + fr += 6; + iteratorAdvanced = true; + vertexProgram.setProgramLocalParameter(index, vec); + } + if (fr.matchSequence("code {")) { std::string code; fr += 2; @@ -74,6 +88,14 @@ bool VertexProgram_writeLocalData(const Object& obj,Output& fw) { const VertexProgram& vertexProgram = static_cast(obj); + const VertexProgram::LocalParamList& lpl = vertexProgram.getLocalParamList(); + VertexProgram::LocalParamList::const_iterator i; + for(i=lpl.begin(); i!=lpl.end(); i++) + { + fw.indent() << "ProgramLocalParameter " << (*i).first << " " << (*i).second << std::endl; + } + + std::vector lines; std::istringstream iss(vertexProgram.getVertexProgram()); std::string line;