From 7cd4641ece5c2462659e813c7b3a75f628d153df Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 15 Aug 2008 16:43:56 +0000 Subject: [PATCH] From Stephane Lamoliatte, "I added the osg::Program parameters support for the osg plug'in. Now we could correctly configure geometry shaders in osg files." Notes from Robert Osfield, renamed the names of the parameters to be less GL centric and more human readable. --- src/osgPlugins/osg/Program.cpp | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/osgPlugins/osg/Program.cpp b/src/osgPlugins/osg/Program.cpp index acb70df8f..5f1b90a62 100644 --- a/src/osgPlugins/osg/Program.cpp +++ b/src/osgPlugins/osg/Program.cpp @@ -9,6 +9,9 @@ using namespace osg; using namespace osgDB; using namespace std; +extern bool Geometry_matchPrimitiveModeStr(const char* str, GLenum& mode); +extern const char* Geometry_getPrimitiveModeStr(GLenum mode); + // forward declare functions to use later. bool Program_readLocalData(Object& obj, Input& fr); bool Program_writeLocalData(const Object& obj, Output& fw); @@ -29,6 +32,35 @@ bool Program_readLocalData(Object& obj, Input& fr) bool iteratorAdvanced = false; Program& program = static_cast(obj); + + if(fr.matchSequence("GeometryVerticesOut %i")) + { + unsigned int verticesOut; + fr[1].getUInt(verticesOut); + program.setParameter(GL_GEOMETRY_VERTICES_OUT_EXT, verticesOut); + fr += 2; + iteratorAdvanced = true; + } + + if(fr.matchSequence("GeometryInputType %w")) + { + std::string primitiveMode = fr[1].getStr(); + GLenum mode; + if(Geometry_matchPrimitiveModeStr(primitiveMode.c_str(), mode)) + program.setParameter(GL_GEOMETRY_INPUT_TYPE_EXT, mode); + fr += 2; + iteratorAdvanced = true; + } + + if(fr.matchSequence("GeometryOutputType %w")) + { + std::string primitiveMode = fr[1].getStr(); + GLenum mode; + if(Geometry_matchPrimitiveModeStr(primitiveMode.c_str(), mode)) + program.setParameter(GL_GEOMETRY_OUTPUT_TYPE_EXT, mode); + fr += 2; + iteratorAdvanced = true; + } while(fr.matchSequence("AttribBindingLocation %i %w")) { @@ -72,6 +104,10 @@ bool Program_readLocalData(Object& obj, Input& fr) bool Program_writeLocalData(const Object& obj,Output& fw) { const Program& program = static_cast(obj); + + fw.indent() << "GeometryVerticesOut " << program.getParameter(GL_GEOMETRY_VERTICES_OUT_EXT) << std::endl; + fw.indent() << "GeometryInputType " << Geometry_getPrimitiveModeStr(program.getParameter(GL_GEOMETRY_INPUT_TYPE_EXT)) << std::endl; + fw.indent() << "GeometryOutputType " << Geometry_getPrimitiveModeStr(program.getParameter(GL_GEOMETRY_OUTPUT_TYPE_EXT)) << std::endl; const Program::AttribBindingList& abl = program.getAttribBindingList(); Program::AttribBindingList::const_iterator i;