cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.24k stars 7.06k forks source link

Cocos2d-x v4 Inconsistent output from RenderTexture between OpenGL and Metal #20612

Open rh101 opened 3 years ago

rh101 commented 3 years ago

Steps to Reproduce:

  1. Generate a new project as you normally would, like this: cocos new gamename -p com.example.gamename -l cpp -d .

  2. Change the code related to displaying the HelloWorld.png in HelloWorldScene::init() to this:

    
    auto sprite = Sprite::create("HelloWorld.png");
    sprite->setFlippedY(true);
    sprite->setPosition(sprite->getContentSize() / 2);
    auto* renderTexture = RenderTexture::create(sprite->getContentSize().width, sprite->getContentSize().height, PixelFormat::RGBA8888);
    renderTexture->beginWithClear(0, 0, 0, 0);
    sprite->visit();
    renderTexture->end();

auto* newSprite = Sprite::createWithTexture(renderTexture->getSprite()->getTexture());

// position the sprite on the center of the screen newSprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

// add the sprite as a child to this layer this->addChild(newSprite, 0);



On Android/Win32 (OpenGL), this is the output:
![image](https://user-images.githubusercontent.com/8603230/99973956-6d107f80-2df4-11eb-9825-1d8af17dae4b.png)

On Mac OS X/iOS (Metal) this is the output:
![image](https://user-images.githubusercontent.com/8603230/99973873-59fdaf80-2df4-11eb-9d7a-cc76e838547d.png)

They should both be the same.  
rh101 commented 3 years ago

@slackmoehrle As requested, adding you to this so you're notified about it. I'm not too familiar with the backend renderers, so I don't know the cause of this issue.

slackmoehrle commented 3 years ago

@minggo can someone take a look at this at this?