Images Getting Streched in the RenderTexture

Hello,

We are trying to create paint app with Undo Redo functionality .

I am creating a renderTexture Like this.

this->canvas = CCRenderTexture::create(CCDirector::sharedDirector()->getWinSize().width-20, 550,kCCTexture2DPixelFormat_RGBA8888); 
canvas->setPosition(ccp(winsize.width/2,winsize.height/2+44));
this->canvas->retain();
this->addChild(canvas,2);

And drawing everything on this renderTexture.

In CCTouchesEnded whatever i have drawn on renderTexture i am saving like this.

UndoMoveData *data = new UndoMoveData();

//creating New renderTextue.
CCRenderTexture  *tex = CCRenderTexture::create(1100, 1396,kCCTexture2DPixelFormat_RGBA4444);
tex->setPosition(ccp(523,579));
tex->retain();

//Copying the canvas contents to new renderTexture
tex->begin();
canvas->visit();
tex->end();

data->lastTexture=tex;

//saving UndoMoveData in the array.
undoArray->addObject(data);
data->release();

OnClick Of Undo

//Retrieving the Undo Object
UndoMoveData *lastTexture=   (UndoMoveData*)undoArray->lastObject();

//Copying the last texture contents to our main canvas
this->canvas->begin();
lastTexture->lastTexture->visit();
this->canvas->end();

Now the problem is after repeated undo redo, texture in the Canvas goes on stretching on some points (Please check the attached screenshots).
This problem appears on Cocos2dx 2.2.3 & even in Cocos2dx 3.1.1

However this problem doesn’t appear on cocos2d iPhone version.

ScreenShots

Thanks
It seems there is a bug in renderTexture, I will try to wrtie a small test case to reproduce the problem,. Could you please try to replace renderTexture->visit() by renderTexture->getSprite()->visit()? For renderTexture->visit() will call begin() and end() internally.

I am getting this issue as well with V3.3. Any news on this?

I have the same issue on 3.2.
Few hints:
Distortion is bigger on border
It looks like scaling problem. Distortion is smaller when I setup setScale to 0.99

Regards
Mariusz

Glad that many people are getting this issue :smile:

This issue is created at https://github.com/cocos2d/cocos2d-x/issues/8533
Unfortunately this was not part of Cocos2d 3.3 release :frowning:
Any update from cocos2d developers will be great.

Getting a similar issue, can be alleviated by applying linear filtering via “setAntiAliasTexParameters” but this causes stretching of the image all the way to the edge.

Did anyone find a solution for this?

Please find the screenshot at the following address, with the result of multiple rendering actions:

It seems that the rendering is made in tiles and maybe the buffer sizes for those tiles are not correctly computed?
Any help would be appreciated!
Thank you!

1 Like

Maybe it is some kind of accumulated error.
I’m looking for a fix for this too.