cocos2dx系列--颜色混合BlendFunc
生活随笔
收集整理的這篇文章主要介紹了
cocos2dx系列--颜色混合BlendFunc
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
[cpp]?view plain?copy struct?CC_DLL?BlendFunc?? {?? ????//!?source?blend?function?? ????GLenum?src;?? ????//!?destination?blend?function?? ????GLenum?dst;?? ?? ????//!?Blending?disabled.?Uses?{GL_ONE,?GL_ZERO}?? ????static?const?BlendFunc?DISABLE;?? ????//!?Blending?enabled?for?textures?with?Alpha?premultiplied.?Uses?{GL_ONE,?GL_ONE_MINUS_SRC_ALPHA}?? ????static?const?BlendFunc?ALPHA_PREMULTIPLIED;?? ????//!?Blending?enabled?for?textures?with?Alpha?NON?premultiplied.?Uses?{GL_SRC_ALPHA,?GL_ONE_MINUS_SRC_ALPHA}?? ????static?const?BlendFunc?ALPHA_NON_PREMULTIPLIED;?? ????//!?Enables?Additive?blending.?Uses?{GL_SRC_ALPHA,?GL_ONE}?? ????static?const?BlendFunc?ADDITIVE;?? ?? ????bool?operator==(const?BlendFunc?&a)?const?? ????{?? ????????return?src?==?a.src?&&?dst?==?a.dst;?? ????}?? ?? ????bool?operator!=(const?BlendFunc?&a)?const?? ????{?? ????????return?src?!=?a.src?||?dst?!=?a.dst;?? ????}?? ?? ????bool?operator<(const?BlendFunc?&a)?const?? ????{?? ????????return?src?<?a.src?||?(src?==?a.src?&&?dst?<?a.dst);?? ????}?? };?? //test?1?? ????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);?? ?? ????BlendFunc?cbl?=?{?GL_SRC_ALPHA?,?GL_ONE?};?? ????sp2->setBlendFunc(cbl);?? ????//test?2?? ????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);?? ?? ????BlendFunc?cb2?=?{GL_ZERO,?GL_ONE};?? ????sp4->setBlendFunc(cb2);?? ????//test?3?? ????Sprite*?sp5?=?Sprite::create("my_test/red.png");?? ????sp5->setPosition(Vec2(400,?200));?? ????addChild(sp5);?? ?? ????Sprite*?sp6?=?Sprite::create("my_test/green.png");?? ????sp6->setPosition(Vec2(420,220));?? ????this->addChild(sp6);?? ?? ????sp6->setBlendFunc(BlendFunc::DISABLE);??
測試結(jié)果如下:
代碼測試如下: [cpp]?view plain?copy
測試結(jié)果如下:
總結(jié)
以上是生活随笔為你收集整理的cocos2dx系列--颜色混合BlendFunc的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 物联网是大家都看好的创业方向
- 下一篇: SAP PP模块常用事务代码