Added public access to VertexProgram's LocalParamters and added .osg support

for these.
This commit is contained in:
Robert Osfield
2004-11-08 17:12:36 +00:00
parent 72b7e08d93
commit 91af37573a
2 changed files with 31 additions and 1 deletions

View File

@@ -172,6 +172,15 @@ class SG_EXPORT VertexProgram : public StateAttribute
_programLocalParameters[index] = p;
}
typedef std::map<GLuint,Vec4> 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<GLuint,Vec4> LocalParamList;
LocalParamList _programLocalParameters;
typedef std::map<GLenum,Matrix> MatrixList;

View File

@@ -31,6 +31,20 @@ bool VertexProgram_readLocalData(Object& obj, Input& fr)
VertexProgram& vertexProgram = static_cast<VertexProgram&>(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<const VertexProgram&>(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<std::string> lines;
std::istringstream iss(vertexProgram.getVertexProgram());
std::string line;