CCRender texture strange bug.

CCRender texture strange bug.
0.0 0



I’ve got a very strange bug related to CCRenderTexture. My code prerenders lots of textured triangles into one big texture.
I want this texture to be used later as some kind of sprite.

Bug appears on ipad1 device with 5.1 ios and contentSacle factor intentionally set to 2.
And it does not appear on iphone with ios 5.1 and contentScale factor set to 1.

On top image I just leave CCRenderTexture object in scene tree (I also tried to create a CCSprite with texture, taken from CCRenderTexture object - it gives the same effect).
Notice glitces on the edges of the green strip.

On bottom image I write down to the device an image with texture contents by simply calling saveToFile(). Then I create new sprite initializing it with image file name, and attach it to the main scene instead of CCRenderTexture object.
Notice, that everything is ok.

I have no idea what causes this. Please, help. :slight_smile:

12.png (77.2 KB)

Cocos-js run in browser

The reason why is because CCRenderTexture defaults to GL_NEAREST for sampling. Your solution works because when you load the texture into a CCSprite, it defaults to GL_LINEAR sampling which enables bilinear filtering.

Calling CCRenderTexture::getSprite()->getTexture()->setAntiAliasTexParameters() should achieve the same results.