Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also on axmol: Cococ2dx issue: FlipY3D issue if setDesignResolution and RenderTexture is used #1069

Closed
aismann opened this issue Feb 22, 2023 · 1 comment

Comments

@aismann
Copy link
Contributor

aismann commented Feb 22, 2023

Steps to Reproduce:
see cocos2d/cocos2d-x#20767
=> has the full source also

here the important source snippet (see on draw()):

#include "HelloWorldScene.h"

USING_NS_AX;

Scene* HelloWorld::createScene()
{
    return HelloWorld::create();
}

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if (!Scene::init())
    {
        return false;
    }

    auto visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    mSpritesLayer = Layer::create();
    mSpritesLayer->retain();

    sprite = Sprite::create("mario_3x.png");
    sprite->getTexture()->setAliasTexParameters();
    sprite->setAnchorPoint(Vec2(0, 1));
    sprite->setScale(visibleSize.height / mDesignSize.height);
    sprite->setPositionY(visibleSize.height);
    sprite->setPositionX(0);
    mSpritesLayer->addChild(sprite);


    // RenderTexture
    mRTex = RenderTexture::create(visibleSize.width, visibleSize.height);
    mRTex->setPosition(visibleSize.width / 2, visibleSize.height / 2);
    this->addChild(mRTex, 100);


    mNodeGrid = NodeGrid::create(Rect(origin,visibleSize));
    mNodeGrid->retain();
    mNodeGrid->setTarget(mSpritesLayer);
    
    mFlipY3dAction = FlipY3D::create(1);
    mFlipY3dAction->retain();

    return true;
}

void HelloWorld::draw(ax::Renderer* renderer, const ax::Mat4& transform, uint32_t flags)
{
    if (mTick == 50)
    {
        mNodeGrid->runAction(mFlipY3dAction);
        mNodeGrid->resume();
    }
    mTick++;
    Scene::draw(renderer, transform, flags);

    // The code below works fine when RenderTexture is not used
  //  mRTex->beginWithClear(0, 0, 0, 0); // comment out and it works
    
    mNodeGrid->visit(renderer, transform, flags); // maybe transform issue?

   // mRTex->end(); // comment out and it works
}

wrong:
image

correct:
image

@aismann aismann changed the title Also on axmol: Cococ2dx issue: https://github.com/cocos2d/cocos2d-x/issues/20767 Also on axmol: Cococ2dx issue: FlipY3D issue if setDesignResolution and RenderTexture is used Feb 22, 2023
@aismann
Copy link
Contributor Author

aismann commented Mar 4, 2023

Removed it. Its also on the cocos forum.

@aismann aismann closed this as completed Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant