RenderToTexture doesn't work

RenderToTexture doesn't work
0.0 0



We create

mRenderTarget = CCRenderTexture::renderTextureWithWidthAndHeight( CCDirector::sharedDirector()->getWinSize().width, CCDirector::sharedDirector()->getWinSize().height );
if (NULL == mRenderTarget)
mRenderTarget->getSprite()->setAnchorPoint(ccp( 0, 1 ));

then we start to draw in a texture

mRenderTarget->setContentSize(CCSize( CCDirector::sharedDirector()->getWinSize().width, CCDirector::sharedDirector()->getWinSize().height));

everything works at Win32, on phone “samsung galaxy s II” occurs freeze pictures and in 59 % cases of aplication crash or a freeze while occurs drawing in a texture.


I have this as well. I’m porting an app from standard cocos2d, and on iOS (coco2dx) It works great, but on android it freezes. I am using it to draw in realtime, so if I try to draw something it’ll lock up for about 5 seconds then draw it all at once on android.

My calls are identical to yours, I’m just calling
mRenderTarget->begin(); otherSprite->vist(); mRenderTarget->end();
In real time, which locks up the thread until it finishes drawing. I’m not sure what the bottleneck on android is, (I’m on a A10 1.0Ghz tablet, so it’s faster than my first gen iPad, which plays smooth).


I’m not sure if this will help your situation, but I tried many things, and eventually came up with ‘another way’ to do this.

Since I couldn’t call this every frame without huge performance problems on android, I now do a mix of custom drawing, and then calling the begin(),visit(),end() every 500 points or so (instead of every one). Now it’s seamless.

In your case try the following, see if it helps:


I get quite a performance gain when that is set to false on android devices, it speeds things up that don’t have good fbo buffers I believe.


Yeap, it records data on Android every frame, we should optimize it.


And what about rendering to texture and zOrder? Do you have some problems with it?

See screenshots in my message.