RenderTexture visit problem

RenderTexture visit problem
0.0 0


Yep, after looking through the search results looks like the others experience nearly the same problems as I do. But with shaders, not with the regular drawing. So, my problem is in the following code:

auto s = Director::getInstance()->getWinSize();
auto _target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
_target->setPosition(Point(s.width / 2, s.height / 2));
addChild(_target, -1);
Sprite * sp = Sprite::createWithSpriteFrameName(art::pathSF[art::eTex_MenuItemLeftArrow]);
sp->setPosition(Point(255, 255));
sp->setAnchorPoint(Point(0, 0));

sp->setPosition(Point(10, 10));
sp->setPosition(Point(50, 50));
sp->setPosition(Point(250, 250));

I expect 3 different images drawn on the _target texture. It performs as expects in Cocos2DX 3.0 Alpha, but in Cocos2DX 3.0 Beta it doesn’t. In Beta all I see is 1 image drawn at position (250, 250). Just look at the attached images if u hadn’t get it yet.
My question is what to do in this case? I want to draw different images on the texture but it seems impossible.

Alpha-result.png (70.4 KB)

Beta-result.png (52.6 KB)

Sprite and multiple visits inside render texture
Copying a small region of a RenderTexture

I bet this is related to the new renderer which utilizes a command queue. Probably the command does not store the state of the object (and this is a correct and optimized solution), so when the commands are being executed the renderer looks up the object’s properties, one of which is the last position you have set.


@Vladimir Lebedev

@dot squid’s answer is correct. Now Sprite::visit doesn’t invoke GL command directly, it just sends data to Renderer. So you should create 3 Sprites for the purpose.