i want to know is there a way to getPixel/setPixel from CCTexture2D
i look into a class CCMutableTexture2D which can do that
and try to convert it to cocos2dx.
but there is a lot of class cocos2dx doesnt support.
like CGContextRef,CGColorSpaceRef …
In cocos2d-iphone, CCTexture2D have no interfaces of getPixel & setPixel, because glReadPixels & glWritePixels have very low performance.
But you can add glReadPixels & glWritePixels into CCTexture2D as you wish, and export interface for your usage.
You talked about CGContextRef,CGColorSpaceRef, they work with CGImage/UIImage, not CCTexture2D. So another approach is to modify CCImage in cocos2d-x, it’ll be more close to your original code. But you had to implement the new interfaces in all your target platforms.
this actually does work, i think the issue is when you apply the texture to the sprite, it anchors the center of the texture to the origin of the sprite. if you translate the sprite to the upper right, you will see the result.
Dmitry Matyukhin wrote:
However, I don’t know why, but another simpler test doesn’t work. It should draw a single diagonal line with random pixels.
>
[…]
>
Anyway, I think, it would be good to get CCRenderTexture and CCTexture2DMutable married together
I just tested it with cocos2d-1.0.1-x-0.13.0-beta. In Android if you change the texSize to NPOT (Not Power Of Two), it just draws white. On iOS it works fine.
Any clue why it does this?