Geometry shader support
This commit is contained in:
@@ -732,6 +732,28 @@ struct ShaderProgramBuilder : PassAttributeBuilder
|
|||||||
const SGReaderWriterXMLOptions* options);
|
const SGReaderWriterXMLOptions* options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
EffectNameValue<GLint> geometryInputTypeInit[] =
|
||||||
|
{
|
||||||
|
{"points", GL_POINTS},
|
||||||
|
{"lines", GL_LINES},
|
||||||
|
{"lines-adjacency", GL_LINES_ADJACENCY_EXT},
|
||||||
|
{"triangles", GL_TRIANGLES},
|
||||||
|
{"triangles-adjacency", GL_TRIANGLES_ADJACENCY_EXT},
|
||||||
|
};
|
||||||
|
EffectPropertyMap<GLint>
|
||||||
|
geometryInputType(geometryInputTypeInit);
|
||||||
|
|
||||||
|
|
||||||
|
EffectNameValue<GLint> geometryOutputTypeInit[] =
|
||||||
|
{
|
||||||
|
{"points", GL_POINTS},
|
||||||
|
{"line-strip", GL_LINE_STRIP},
|
||||||
|
{"triangle-strip", GL_TRIANGLE_STRIP}
|
||||||
|
};
|
||||||
|
EffectPropertyMap<GLint>
|
||||||
|
geometryOutputType(geometryOutputTypeInit);
|
||||||
|
|
||||||
void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
||||||
const SGPropertyNode* prop,
|
const SGPropertyNode* prop,
|
||||||
const SGReaderWriterXMLOptions*
|
const SGReaderWriterXMLOptions*
|
||||||
@@ -741,6 +763,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
|||||||
if (!isAttributeActive(effect, prop))
|
if (!isAttributeActive(effect, prop))
|
||||||
return;
|
return;
|
||||||
PropertyList pVertShaders = prop->getChildren("vertex-shader");
|
PropertyList pVertShaders = prop->getChildren("vertex-shader");
|
||||||
|
PropertyList pGeomShaders = prop->getChildren("geometry-shader");
|
||||||
PropertyList pFragShaders = prop->getChildren("fragment-shader");
|
PropertyList pFragShaders = prop->getChildren("fragment-shader");
|
||||||
PropertyList pAttributes = prop->getChildren("attribute");
|
PropertyList pAttributes = prop->getChildren("attribute");
|
||||||
ProgramKey prgKey;
|
ProgramKey prgKey;
|
||||||
@@ -750,6 +773,12 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
|||||||
++itr)
|
++itr)
|
||||||
prgKey.shaders.push_back(ShaderKey((*itr)->getStringValue(),
|
prgKey.shaders.push_back(ShaderKey((*itr)->getStringValue(),
|
||||||
Shader::VERTEX));
|
Shader::VERTEX));
|
||||||
|
for (PropertyList::iterator itr = pGeomShaders.begin(),
|
||||||
|
e = pGeomShaders.end();
|
||||||
|
itr != e;
|
||||||
|
++itr)
|
||||||
|
prgKey.shaders.push_back(ShaderKey((*itr)->getStringValue(),
|
||||||
|
Shader::GEOMETRY));
|
||||||
for (PropertyList::iterator itr = pFragShaders.begin(),
|
for (PropertyList::iterator itr = pFragShaders.begin(),
|
||||||
e = pFragShaders.end();
|
e = pFragShaders.end();
|
||||||
itr != e;
|
itr != e;
|
||||||
@@ -781,7 +810,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
|||||||
// Add vertex shaders, then fragment shaders
|
// Add vertex shaders, then fragment shaders
|
||||||
PropertyList& pvec = pVertShaders;
|
PropertyList& pvec = pVertShaders;
|
||||||
Shader::Type stype = Shader::VERTEX;
|
Shader::Type stype = Shader::VERTEX;
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
for (PropertyList::iterator nameItr = pvec.begin(), e = pvec.end();
|
for (PropertyList::iterator nameItr = pvec.begin(), e = pvec.end();
|
||||||
nameItr != e;
|
nameItr != e;
|
||||||
++nameItr) {
|
++nameItr) {
|
||||||
@@ -802,13 +831,35 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pvec = pFragShaders;
|
if (i == 0) {
|
||||||
stype = Shader::FRAGMENT;
|
pvec = pGeomShaders;
|
||||||
|
stype = Shader::GEOMETRY;
|
||||||
|
} else {
|
||||||
|
pvec = pFragShaders;
|
||||||
|
stype = Shader::FRAGMENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(const ProgramKey::AttribKey& key, prgKey.attributes) {
|
BOOST_FOREACH(const ProgramKey::AttribKey& key, prgKey.attributes) {
|
||||||
program->addBindAttribLocation(key.first, key.second);
|
program->addBindAttribLocation(key.first, key.second);
|
||||||
}
|
}
|
||||||
programMap.insert(ProgramMap::value_type(prgKey, program));
|
const SGPropertyNode* pGeometryVerticesOut = getEffectPropertyChild(effect, prop, "geometry-vertices-out");
|
||||||
|
if ( pGeometryVerticesOut ) {
|
||||||
|
program->setParameter( GL_GEOMETRY_VERTICES_OUT_EXT, pGeometryVerticesOut->getIntValue() );
|
||||||
|
}
|
||||||
|
const SGPropertyNode* pGeometryInputType = getEffectPropertyChild(effect, prop, "geometry-input-type");
|
||||||
|
if ( pGeometryInputType ) {
|
||||||
|
GLint type;
|
||||||
|
findAttr( geometryInputType, pGeometryInputType->getStringValue(), type );
|
||||||
|
program->setParameter( GL_GEOMETRY_INPUT_TYPE_EXT, type );
|
||||||
|
}
|
||||||
|
const SGPropertyNode* pGeometryOutputType = getEffectPropertyChild(effect, prop, "geometry-output-type");
|
||||||
|
if ( pGeometryOutputType ) {
|
||||||
|
GLint type;
|
||||||
|
findAttr( geometryOutputType, pGeometryOutputType->getStringValue(), type );
|
||||||
|
program->setParameter( GL_GEOMETRY_OUTPUT_TYPE_EXT, type );
|
||||||
|
}
|
||||||
|
|
||||||
|
programMap.insert(ProgramMap::value_type(prgKey, program));
|
||||||
}
|
}
|
||||||
pass->setAttributeAndModes(program);
|
pass->setAttributeAndModes(program);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user