[Public WebGL] Oversight in bufferData and bufferSubData specification

Chris Marrin [email protected]
Tue May 24 09:03:19 PDT 2011


On May 23, 2011, at 10:18 PM, Cedric Vivier wrote:

> 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
> reported.
> In conjunction with the fact that all numbers are double-precision
> 64-bit in Javascript, this not obey the principle of least surprise.

You have to make a very conscious effort to make a Float64Array, so the native size of JS float is not the point. If I pass an Int32Array and set the type to gl.FLOAT that's an error that will not be reported.

This is an issue developers have to be careful about no matter how we treat Float64Array.

-----
~Chris
[email protected]




-----------------------------------------------------------
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