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.12k stars 7.05k forks source link

RenderTexture with sprite3d show error #12353

Open flamefox opened 9 years ago

flamefox commented 9 years ago

make a function and create a rendertextue

        renderTexture = RenderTexture::create(100, 100, Texture2D::PixelFormat::RGBA8888);
        renderTexture->retain();

then use it at sprite3d

   this->setVisible(true);
    renderTexture->setAutoDraw(false);
    auto renderer = cocos2d::Director::getInstance()->getRenderer();
    //init the visibleCamera
    cocos2d::Director::getInstance()->getRunningScene()->InitVisCamera(this->getCameraMask());

    renderTexture->beginWithClear(0.0f, 0.0f, 0.0f, 0.0f, 1.0f); 

    this->visit(renderer, this->getNodeToWorldTransform(), 0);  
    renderTexture->end();
   //render it
    renderer->render();
      cocos2d::Director::getInstance()->getRunningScene()->ClearVisCamera();
    this->setVisible(false);

    return renderTexture->getSprite();

if I modify the code of meshcommand _is3d to false and set the

flags &= ~FLAGS_RENDER_AS_3D;
meshCommand.set3D(false);

it show with no depthtest, img

IgorMats commented 8 years ago

Bump)

polluxchi commented 8 years ago

The problem is still in 3.12.

RustyMoyher commented 7 years ago

I think your Sprite3D bug is similar to mine: Issue #16894. See this issue for the fix. I've also added an answer to this Stack Overflow question.