I was wondering who was deciding what was going into the API, and how best I could harass them
Specifically, right now I’m using readPixels, and this returns a new pixel array each call. The native API is much smarter about this and just takes a destination pointer, allowing you to pass your own buffer. I can see how having readPixels return an array is simpler, however if you are doing full-screen reads (or even moderately large ones) each frame you end up creating many mb of garbage each frame.
It would be nice if the call could take an array as an argument - maybe if you omit it you still get the new array back (just like today), but if it’s passed in it’ll use that.
var pixels = gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE);
var myBuffer = new WebGLUnsignedByteArray(width * height * 4);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, myBuffer);
Then you can be smart and keep myBuffer around, preventing tons of memory churn.