]> git.mxchange.org Git - simgear.git/commitdiff
Add alpha-to-coverage GL parameter to effects code.
authorStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Tue, 25 Sep 2012 21:51:37 +0000 (22:51 +0100)
committerStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Tue, 25 Sep 2012 21:51:37 +0000 (22:51 +0100)
simgear/scene/material/Effect.cxx

index c934815760ced8359c0c3678fde2e9b865544deb..e607c2e5bb6e4e45e7eca14bc71094e146faeb84 100644 (file)
@@ -602,6 +602,24 @@ struct StencilBuilder : public PassAttributeBuilder
 
 InstallAttributeBuilder<StencilBuilder> installStencil("stencil");
 
+struct AlphaToCoverageBuilder : public PassAttributeBuilder
+{
+    void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop,
+                        const SGReaderWriterOptions* options);
+};
+
+void AlphaToCoverageBuilder::buildAttribute(Effect* effect, Pass* pass,
+                                     const SGPropertyNode* prop,
+                                     const SGReaderWriterOptions* options)
+{
+    const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop);
+    if (!realProp)
+        return;
+    pass->setMode(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, (realProp->getValue<bool>() ? 
+                                    StateAttribute::ON : StateAttribute::OFF));
+}
+
+InstallAttributeBuilder<AlphaToCoverageBuilder> installAlphaToCoverage("alpha-to-coverage");
 
 EffectNameValue<AlphaFunc::ComparisonFunction> alphaComparisonInit[] =
 {
@@ -648,6 +666,7 @@ struct AlphaTestBuilder : public PassAttributeBuilder
                                                              "comparison");
         const SGPropertyNode* pRef = getEffectPropertyChild(effect, prop,
                                                              "reference");
+
         AlphaFunc::ComparisonFunction func = AlphaFunc::ALWAYS;
         float refValue = 1.0f;
         if (pComp)