}
+void
+FGRenderingPipeline::Conditionable::parseCondition(SGPropertyNode* prop)
+{
+ const SGPropertyNode* predProp = prop->getChild("condition");
+ if (!predProp) {
+ setAlwaysValid(true);
+ } else {
+ setAlwaysValid(false);
+ try {
+ flightgear::PipelinePredParser parser;
+ SGExpressionb* validExp = dynamic_cast<SGExpressionb*>(parser.read(predProp->getChild(0)));
+ if (validExp)
+ setValidExpression(validExp);
+ else
+ throw simgear::expression::ParseError("pipeline condition is not a boolean expression");
+ }
+ catch (simgear::expression::ParseError& except)
+ {
+ SG_LOG(SG_INPUT, SG_ALERT,
+ "parsing pipeline condition " << except.getMessage());
+ setAlwaysValid(false);
+ }
+ }
+}
+
+void FGRenderingPipeline::Conditionable::setValidExpression(SGExpressionb* exp)
+{
+ _validExpression = exp;
+}
+
+bool FGRenderingPipeline::Conditionable::valid()
+{
+ return _alwaysValid || _validExpression->getValue();
+}
+
template<typename T>
void findAttrOrHex(const simgear::effect::EffectPropertyMap<T>& pMap,
const SGPropertyNode* prop,
if (!nameProp.valid()) {
throw sg_exception("Buffer name is mandatory");
}
+ internalFormat = GL_RGBA8;
+ sourceFormat = GL_RGBA;
+ sourceType = GL_UNSIGNED_BYTE;
+ wrapMode = GL_CLAMP_TO_BORDER_ARB;
name = nameProp->getStringValue();
- findAttrOrHex(internalFormats, prop->getChild("internal-format"), internalFormat);
- findAttrOrHex(sourceFormats, prop->getChild("source-format"), sourceFormat);
- findAttrOrHex(sourceTypes, prop->getChild("source-type"), sourceType);
- findAttrOrHex(wrapModes, prop->getChild("wrap-mode"), wrapMode);
+ SGPropertyNode* internalFormatProp = prop->getChild("internal-format");
+ if (internalFormatProp)
+ findAttrOrHex(internalFormats, internalFormatProp, internalFormat);
+ SGPropertyNode* sourceFormatProp = prop->getChild("source-format");
+ if (sourceFormatProp)
+ findAttrOrHex(sourceFormats, sourceFormatProp, sourceFormat);
+ SGPropertyNode* sourceTypeProp = prop->getChild("source-type");
+ if (sourceTypeProp)
+ findAttrOrHex(sourceTypes, sourceTypeProp, sourceType);
+ SGPropertyNode* wrapModeProp = prop->getChild("wrap-mode");
+ if (wrapModeProp)
+ findAttrOrHex(wrapModes, wrapModeProp, wrapMode);
SGConstPropertyNode_ptr widthProp = getPropertyChild(prop, "width");
if (!widthProp.valid())
width = -1;
scaleFactor = prop->getFloatValue("scale-factor", 1.f);
shadowComparison = prop->getBoolValue("shadow-comparison", false);
+
+ parseCondition(prop);
}
simgear::effect::EffectNameValue<osg::Camera::BufferComponent> componentsInit[] =
};
simgear::effect::EffectPropertyMap<osg::Camera::BufferComponent> components(componentsInit);
-FGRenderingPipeline::Stage::Stage(SGPropertyNode* prop)
+FGRenderingPipeline::Pass::Pass(SGPropertyNode* prop)
{
SGPropertyNode_ptr nameProp = prop->getChild("name");
if (!nameProp.valid()) {
- throw sg_exception("Stage name is mandatory");
+ throw sg_exception("Pass name is mandatory");
}
name = nameProp->getStringValue();
SGPropertyNode_ptr typeProp = prop->getChild("type");
}
orderNum = prop->getIntValue("order-num", -1);
-
effect = prop->getStringValue("effect", "");
+ parseCondition(prop);
+}
+
+FGRenderingPipeline::Stage::Stage(SGPropertyNode* prop) : Pass(prop)
+{
+ needsDuDv = prop->getBoolValue("needs-du-dv", false);
+ scaleFactor = prop->getFloatValue("scale-factor", 1.f);
+
std::vector<SGPropertyNode_ptr> attachments = prop->getChildren("attachment");
for (int i = 0; i < (int)attachments.size(); ++i) {
this->attachments.push_back(new FGRenderingPipeline::Attachment(attachments[i]));
}
+
+ std::vector<SGPropertyNode_ptr> passes = prop->getChildren("pass");
+ for (int i = 0; i < (int)passes.size(); ++i) {
+ this->passes.push_back(new FGRenderingPipeline::Pass(passes[i]));
+ }
}
FGRenderingPipeline::Attachment::Attachment(SGPropertyNode* prop)
throw sg_exception("Attachment buffer is mandatory");
}
buffer = bufferProp->getStringValue();
+
+ parseCondition(prop);
}
FGRenderingPipeline::FGRenderingPipeline()