Ashar
Ashar

Reputation: 217

how to make CCRenderTexture transparent

i'm trying to make CCRenderTexture's empty parts transparent instead of black in Cocoss2d-x. Is there any solution?

Here's my code

cocos2d::CCPoint screenMid = ccp(size.width * 0.5f, size.height * 0.5f);

CCRenderTexture * masked = CCRenderTexture::create(size.width, size.height);    
masked->getSprite()->setBlendFunc((ccBlendFunc) { GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA });
masked->setPosition(screenMid);
this->addChild(masked);

Upvotes: 0

Views: 1092

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

Normally there should be a "clear" function that you call before drawing anything onto the render texture. At least in cocos2d-iphone version there's one.

If you set the clear color to use 0.0 alpha then that'll make the render texture fully transparent initally.

Upvotes: 1

Related Questions