From a543560f7db48e5c91d7551f93ba9740e1a7061f Mon Sep 17 00:00:00 2001 From: PSadrozinski Date: Sun, 6 Nov 2011 09:47:29 -0500 Subject: [PATCH] Adding Icecode GL's polygon-offset support for effects --- simgear/scene/material/Effect.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index 33e272c1..1a52c659 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -1059,6 +1060,34 @@ struct PolygonModeBuilder : public PassAttributeBuilder InstallAttributeBuilder installPolygonMode("polygon-mode"); +struct PolygonOffsetBuilder : public PassAttributeBuilder +{ + void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop, + const SGReaderWriterXMLOptions* options) + { + if (!isAttributeActive(effect, prop)) + return; + + const SGPropertyNode* factor + = getEffectPropertyChild(effect, prop, "factor"); + const SGPropertyNode* units + = getEffectPropertyChild(effect, prop, "units"); + + ref_ptr polyoffset = new PolygonOffset; + + polyoffset->setFactor(factor->getFloatValue()); + polyoffset->setUnits(units->getFloatValue()); + + SG_LOG(SG_INPUT, SG_BULK, + "Set PolygonOffset to " << polyoffset->getFactor() << polyoffset->getUnits() ); + + pass->setAttributeAndModes(polyoffset.get(), + StateAttribute::OVERRIDE|StateAttribute::ON); + } +}; + +InstallAttributeBuilder installPolygonOffset("polygon-offset"); + struct VertexProgramTwoSideBuilder : public PassAttributeBuilder { void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop, -- 2.39.5