[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Reading out the color value stored in FBO with Chromium



The problem is in your readPixels function.  RGB is no longer valid.
For WebGL, only RGBA/UNSIGNED_BYTE are supported.

If firefox gives you the pixel data, it's a bug they should fix.  An
error (INVALID_OPERATION) should be generated instead.

Mo

On Wed, Nov 10, 2010 at 12:45 PM, M.Sirin <m.sirin07@googlemail.com> wrote:
> Hi,
> after I defined a framebuffer object and using it for colorpicking, it works
> without any problems in firefox/minefield. But there must be something
> wrong, because Chromium 9.0.564.0 (63713) isn't doing anything when trying
> to read the color value stored in the fbo.
> This is how I'm defining and using the stuff:
> 1. FBO:
> -----------------------------------------------------
> fbo=gl.createFramebuffer();
> gl.bindFramebuffer(gl.FRAMEBUFFER,fbo);
> var rbDepth=gl.createRenderbuffer();
> gl.bindRenderbuffer(gl.RENDERBUFFER,rbDepth);
> var
> rbDepthStorage=gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_COMPONENT16,canvas.width
> ,canvas.height);
> gl.framebufferRenderbuffer(gl.FRAMEBUFFER,gl.DEPTH_ATTACHMENT,gl.RENDERBUFFER,rbDepth);
> var texture=gl.createTexture();
> gl.bindTexture(gl.TEXTURE_2D,texture);
> gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,canvas.width
> ,canvas.height,0,gl.RGBA,gl.UNSIGNED_BYTE,null);
> gl.framebufferTexture2D(gl.FRAMEBUFFER,gl.COLOR_ATTACHMENT0,gl.TEXTURE_2D,texture,0);
>
> 2. After making a common drawArrays-call:
> -------------------------------------------------
> gl.bindFramebuffer(gl.FRAMEBUFFER,fbo);
> //send unique color to shader & deactivate all lightening etc.
> //another drawArrays-call
> gl.bindFramebuffer(gl.FRAMEBUFFER,null);
>
> 3. In case of refreshing the scene:
> -------------------------------------------------
>    gl.bindFramebuffer(gl.FRAMEBUFFER,fbo);
>    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
>    gl.clearColor(0.0,0.0,0.0,1.0)
>    gl.enable(gl.DEPTH_TEST);
>
>    gl.bindFramebuffer(gl.FRAMEBUFFER,null);
>    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
>    gl.clearColor(0.0,0.0,0.0,1.0)
>    gl.enable(gl.DEPTH_TEST);
>
>    gl.viewport(0, 0, canvas.clientWidth, canvas.clientHeight);
> ...
> 4. Read color that was previously stored in the fbo:
> -------------------------------------------------
>  gl.bindFramebuffer(gl.FRAMEBUFFER,fbo);
>   var pix = new Uint8Array(4);
>   gl.readPixels(xCoord-10, canvas.clientHeight-yCoord+37, 1, 1,
> gl.RGB,gl.UNSIGNED_BYTE,pix);
>   alert(pix[0],pix[1],pix[2]);
>
> Output:
>   alert with firefox e.g.: 0 0 9 which is correct
>   alert with Chromium is always 0 0 0 which is of course not correct
>
>
> I guess there is something wrong in the first step, i.e. the definition of
> the FBO ?
>
> regards
> m.sirin
>

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: