1 #include <simgear/compiler.h>
3 #include "parseBlendFunc.hxx"
4 #include <simgear/props/props.hxx>
5 #include <osg/BlendFunc>
9 #define COMPARE(a, b) \
12 std::cerr << "line " << __LINE__ << ": failed: "\
13 << #a << " != " << #b << std::endl; \
20 std::cerr << "line " << __LINE__ << ": failed: "\
25 int main (int ac, char ** av)
27 osg::ref_ptr<osg::StateSet> ss = new osg::StateSet;
30 VERIFY( simgear::parseBlendFunc(ss) );
32 osg::BlendFunc* bf = dynamic_cast<osg::BlendFunc*>(
33 ss->getAttribute(osg::StateAttribute::BLENDFUNC)
37 COMPARE(bf->getSource(), osg::BlendFunc::SRC_ALPHA);
38 COMPARE(bf->getDestination(), osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
39 COMPARE(bf->getSource(), bf->getSourceAlpha());
40 COMPARE(bf->getDestination(), bf->getDestinationAlpha());
42 // now set some values
43 SGPropertyNode_ptr src = new SGPropertyNode,
44 dest = new SGPropertyNode;
46 src->setStringValue("src-alpha");
47 dest->setStringValue("constant-color");
49 VERIFY( simgear::parseBlendFunc(ss, src, dest) );
51 bf = dynamic_cast<osg::BlendFunc*>(
52 ss->getAttribute(osg::StateAttribute::BLENDFUNC)
56 COMPARE(bf->getSource(), osg::BlendFunc::SRC_ALPHA);
57 COMPARE(bf->getDestination(), osg::BlendFunc::CONSTANT_COLOR);
58 COMPARE(bf->getSource(), bf->getSourceAlpha());
59 COMPARE(bf->getDestination(), bf->getDestinationAlpha());
61 std::cout << "all tests passed successfully!" << std::endl;