RenderTexture bug on cocos2d-js on Android?

I’m trying to detect per pixel touches using a RenderTexture but while it’s working fine on html5 it’s not working on Android.
On Android gl.readPixels returns wrong pixels probably from the main framebuffer, not the cc.RenderTexture.
gl.getError and gl.checkFramebufferStatus return OK values.
Am I doing something wrong or it’s a cocos2d-js bug?
Thanks.

How did you do that exactly ?

Because Cocos2d-JS uses cocos2d-x’s new renderer, so the real render process is not available directly for developers to control.

My code looks like this and it’s working on Chrome so it’s not totally wrong:

rt = new cc.RenderTexture(screen.width, screen.height, cc.Texture2D.PIXEL_FORMAT_RGBA8888);
rt.beginWithClear(0, 0, 0, 0);

mysprite.visit();

var a = this.readPixels(x, y, 1, 1);
rt.end();

For debugging I have tried reading multiple pixels at once and draw them and they are from a random position from the main framebuffer (on Android). I’m using Cocos2d-js RC3

I got this idea from per pixel collision detection examples I’ve seen. If this is not going to work because of the new rendering process is there any other way?
Thanks a lot.

@pandamicro Any news on this?

For any soul trying to do this in JS: it can’t be done. The render in 3.0 is asynchronous.
In C++ it could work as shown here.
But in JS you can not force a render. There is not a cc.director.renderer.render() function.

1 Like

We will consider to bind the renderer

1 Like