Help me with blending function. Cant make a hole in background

Hi! I cant make a hole in background with a help of partially transparent mask. Transparent part of mask fills with black color instead of transparency.
I have OPENGL initialization:

void AppDelegate::initGLContextAttrs()
{
   GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
   GLView::setGLContextAttrs(glContextAttrs);
}

I have several images for testing:
lower back

higher back

mask sprite

and when I init my scene I code this:

Sprite* lower_back = Sprite::create("scenes/lower_back.png");
lower_back->setBlendFunc(BlendFunc::DISABLE);
lower_back->setAnchorPoint(Vec2(0, 0));
lower_back->setPosition(Vec2(0, 0));
addChild(lower_back);

Sprite* higher_back = Sprite::create("scenes/higher_back.png");
higher_back->setBlendFunc({ GL_ONE,GL_ONE});
higher_back->setAnchorPoint(Vec2(0, 0));
higher_back->setPosition(Vec2(50, 50));
lower_back->addChild(higher_back);

glEnable(GL_BLEND);  
glBlendEquation(GL_FUNC_ADD);

Sprite* mask_sprite = Sprite::create("scenes/mask_sprite.png");
mask_sprite->setBlendFunc({ GL_ZERO,GL_ONE_MINUS_SRC_ALPHA});
mask_sprite->setAnchorPoint(Vec2(0, 0));
mask_sprite->setPosition(Vec2(100, 100));
higher_back->addChild(mask_sprite);

And the result is:

Why there is a black hole , not transparent. I say to src GL_ZERO but it takes the black result.
Help me please. I have tested it on android device and result is the same. What am I doing wrong?

Fixed problem. If anyone has the same problem, here is my solution:

Sprite* lower_back = Sprite::create("scenes/lower_back.png");
lower_back->setBlendFunc(BlendFunc::DISABLE);
lower_back->setAnchorPoint(Vec2(0, 0));
lower_back->setPosition(Vec2(0, 0));
addChild(lower_back,1);

Sprite* higher_back = Sprite::create("scenes/higher_back.png");
higher_back->setBlendFunc(BlendFunc::DISABLE);
higher_back->setAnchorPoint(Vec2(0, 0));
higher_back->setPosition(Vec2(50, 50));
higher_back->retain();

Sprite* mask_sprite = Sprite::create("scenes/mask_sprite.png");
mask_sprite->setBlendFunc({ GL_ZERO,GL_ONE_MINUS_SRC_ALPHA});
mask_sprite->setAnchorPoint(Vec2(0, 0));
mask_sprite->setPosition(Vec2(300, 300));
mask_sprite->retain();

Sprite* mask_sprite2 = Sprite::create("scenes/mask_sprite.png");
mask_sprite2->setBlendFunc({ GL_ZERO,GL_ONE_MINUS_SRC_ALPHA});
mask_sprite2->setAnchorPoint(Vec2(0, 0));
mask_sprite2->setPosition(Vec2(350, 350));
mask_sprite2->retain();

RenderTexture*rendText = RenderTexture::create(1024 , 768);
rendText->setPosition(Vec2(512, 384));
rendText->setAnchorPoint(Vec2(0, 0));
this->addChild(rendText);

rendText->begin();
higher_back->visit();
mask_sprite->visit();
mask_sprite2->visit();
rendText->end();

I pushed all operations to an individual render texture and everything worked!
Screen result is:

2 Likes