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

Re: [Public WebGL] Should bufferData record array type?

I don't think this can (or should) work.

First, passing ArrayBuffer (untyped) is completely valid and useful. There's no way to track type on this.

Second, using combined types in the same buffer is a very common practice - in this case, one often passes just the ArrayBuffer, but there's nothing preventing them from passing one of the data arrays instead.
Right, so let's forget about this. Thanks for the reality check. I only thought about the specific case of passing a  typed array of a certain type and using it as a single attrib of a different type, and didn't think about the rest.

Still, it's a pity that we can't do anything to ban that (passing a  typed array of a certain type and using it as a single attrib of a different type).


For example:
var data = "" ArrayBuffer(123);
var floats = new Float32Array(data);
var bytes = new Uint8Array(data);
// write vertices as floats, colors as bytes, etc
gl.bufferData(...., data, ...); // works, valid, no type can be known by bufferData
gl.bufferData(...., floats, ...); // works, valid, floats just references floats.buffer (which is 'data'), and contains multiple types, so no type can be known

On Tue, Jan 24, 2012 at 1:25 PM, Benoit Jacob <bjacob@mozilla.com> wrote:


Currently, as far as I can see, we're not checking the type of the array passed to bufferData. So you could pass an array of uint8's to bufferData and later use that buffer in a vertex attrib of a different type, say floats.

I would suggest that (not for 1.0.1 but for a future 1.0.2) we specify that buffers are typed, that the type is set when calling bufferData, and that bufferSubData and vertexAttribPointer must generate an error in case of type mismatch. Or, do you see any reason why this would break reasonable content?


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:
unsubscribe public_webgl