RenderTexture reusage

RenderTexture reusage
0.0 0


Hello, I have to generate some portion of sprites using rendering to texture technique. The problem is that after mRenderTexture->end(); I have to store rendered data before draw into the same render texture (I don’t want to create one render texture per each generated sprite).

CCSprite* rtSprite = CCSprite::createWithTexture( mRenderTexture->getSprite()->getTexture() );

BUT. All the generated sprites are linked to the one texture which is related to render texture. So all of them would contain the result of the last draw into render texture.

How to FULL copy the content of the texture or I have to create for each sprite new render texture?


Use newCCImage to get pixmap, than convert pixmap to texture. You also can save RenderTexture to file (actually this operation calls newCCImage inside) and than load saved file as sprite.


Thank you. Are file operations faster than intialization of frame buffer?


Things can change on another hardware, but usually initialization is faster than reading pixels and loading them to new texture. Also you can try glCopyTexSubImage2D.