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.
This commit is contained in:
Robert Osfield 2008-08-15 16:43:56 +00:00
parent 38f6cddc2c
commit 7cd4641ece

View File

@ -9,6 +9,9 @@ using namespace osg;
using namespace osgDB; using namespace osgDB;
using namespace std; 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. // forward declare functions to use later.
bool Program_readLocalData(Object& obj, Input& fr); bool Program_readLocalData(Object& obj, Input& fr);
bool Program_writeLocalData(const Object& obj, Output& fw); bool Program_writeLocalData(const Object& obj, Output& fw);
@ -29,6 +32,35 @@ bool Program_readLocalData(Object& obj, Input& fr)
bool iteratorAdvanced = false; bool iteratorAdvanced = false;
Program& program = static_cast<Program&>(obj); Program& program = static_cast<Program&>(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")) 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) bool Program_writeLocalData(const Object& obj,Output& fw)
{ {
const Program& program = static_cast<const Program&>(obj); const Program& program = static_cast<const Program&>(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(); const Program::AttribBindingList& abl = program.getAttribBindingList();
Program::AttribBindingList::const_iterator i; Program::AttribBindingList::const_iterator i;