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

Re: [Public WebGL] inconsistent clear behavior for preserveDrawingBuffer: false (the default)





On 02/06/2012 06:15, Benoit Jacob wrote:
In the sample I clear the drawing buffer to green. Then 1 second later I issue some GL commands to see what happens. ÂThese 6 commands should not effect what is displayed

   ÂÂgl.enable(gl.BLEND);
   ÂÂgl.bindTexture(gl.TEXTURE_2D, gl.createTexture());
   ÂÂgl.viewport(1,1,1,1);
   ÂÂgl.bindFramebuffer(gl.FRAMEBUFFER, null);
    var p = new Uint8Array(4);
    gl.readPixels(0,0,1,1,gl.RGBA,gl.UNSIGNED_BYTE, p);

What I find is Firefox ends up reflecting that the backbuffer has been cleared if I call gl.readPixels. On other words it recomposites the page with the cleared drawing buffer. As far as I can tell from the spec that's a bug. The drawing buffer has not been modified so Âit should not be composited again.
In Mozilla's implementation, readPixel checks if the backbuffer needs a clear (which is the case if preserveDrawingBuffer is false and the drawing buffer hasn't been cleared since it was last presented). If it does find that it needs a clear, then it clears it and requests it to be composited again.

How else should it behave?

Clearing the drawing buffer is correct. Requesting a re-composite is incorrect since the buffer has not been modified by the application.

Regards

ÂÂÂ -Mark