[Public WebGL] Oversight in bufferData and bufferSubData specification

Cedric Vivier [email protected]
Mon May 23 22:18:12 PDT 2011

On Tue, May 24, 2011 at 03:02, Gregg Tavares (wrk) <[email protected]> wrote:
>> Consider a much simpler example :
>> readModelInto(float64ArrayThatHasBeenCreatedElsewhere); //this fills
>> the values of any passed TypedArray from another source eg. a JSON
>> array.
>> gl.bufferData(gl.ARRAY_BUFFER, float64ArrayThatHasBeenCreatedElsewhere);
>> This will result in unintended/unexpected results that the developer
>> might have hard time to track down as there is absolutely no
>> warning/error given to something that is semantically wrong.
> No it won't. There is no gl.DOUBLE to pass to gl.vertexAttribPointer.

That's the problem, vertexAttribPointer will be set to gl.FLOAT
already, the output will be garbage and there won't be any error
In conjunction with the fact that all numbers are double-precision
64-bit in Javascript, this not obey the principle of least surprise.

> Most samples that used
> mixed types upload all their data through a UInt8Array or Float32Array even
> though their data is not uniformly gl.UNSIGNED_BYTE or gl.FLOAT

Uniformity is not relevant here.
If you upload an UInt8Array, you convey the intent that you will
likely use at least one attrib of UNSIGNED_BYTE.
If you upload an Float32Array, you convey the intent that you will
likely use at least one attrib of FLOAT.

As you'll never be able to use one attrib of DOUBLE, it breaks this "contract".

> Disallowing Float64Array will not help the developer in any way

As clarified above, I still think it can help the developer for simple
typos/mistakes that would otherwise take some time to figure out.

Not feeling strongly about inclusion in the spec though, it could be
done out of spec by tools like WebGL Inspector.

You are currently subscribed to [email protected]
To unsubscribe, send an email to [email protected] with
the following command in the body of your email:
unsubscribe public_webgl

More information about the public_webgl mailing list