- structCC_DLLBlendFunc
- {
- //!sourceblendfunction
- GLenumsrc;
- //!destinationblendfunction
- GLenumdst;
- //!Blendingdisabled.Uses{GL_ONE,GL_ZERO}
- staticconstBlendFuncDISABLE;
- //!BlendingenabledfortextureswithAlphapremultiplied.Uses{GL_ONE,GL_ONE_MINUS_SRC_ALPHA}
- constBlendFuncALPHA_PREMULTIPLIED;
- //!BlendingenabledfortextureswithAlphaNONpremultiplied.Uses{GL_SRC_ALPHA,153);border:none;background-color:inherit;">constBlendFuncALPHA_NON_PREMULTIPLIED;
- //!EnablesAdditiveblending.Uses{GL_SRC_ALPHA,GL_ONE}
- constBlendFuncADDITIVE;
- booloperator==(constBlendFunc&a)const
- returnsrc==a.src&&dst==a.dst;
- }
- booloperator!=(const
- {
- returnsrc!=a.src||dst!=a.dst;
- }
- booloperator<(returnsrc<a.src||(src==a.src&&dst<a.dst);
- };
代码测试如下:
//test1
Sprite*sp1=Sprite::create("my_test/red.png");
sp1->setPosition(Vec2(200,200));
addChild(sp1);
Sprite*sp2=Sprite::create("my_test/green.png");
sp2->setPosition(Vec2(220,220));
this->addChild(sp2);
BlendFunccbl={GL_SRC_ALPHA,GL_ONE};
sp2->setBlendFunc(cbl);
//test2
Sprite*sp3=Sprite::create("my_test/red.png");
sp3->setPosition(Vec2(300,200));
addChild(sp3);
Sprite*sp4=Sprite::create("my_test/green.png");
sp4->setPosition(Vec2(320,220));
this->addChild(sp4);
BlendFunccb2={GL_ZERO,GL_ONE};
sp4->setBlendFunc(cb2);
//test3
Sprite*sp5=Sprite::create(sp5->setPosition(Vec2(400,0);background-color:inherit;">addChild(sp5);
Sprite*sp6=Sprite::create(sp6->setPosition(Vec2(420,153);border:none;background-color:inherit;">this->addChild(sp6);
sp6->setBlendFunc(BlendFunc::DISABLE);
测试结果如下: