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

Re: [Public WebGL] Working with TypedArrays and heterogeneous data



On 10/13/2010 12:08 PM, Vladimir Vukicevic wrote:
----- Original Message -----
Hi

There are two forms of the gl.bindBuffer call - one has an ArrayBuffer
parameter and one has an
ArrayBufferView parameter. As far as I can see from looking at the
source for WebKit, the actual
type of the ArrayBufferView is ignored and its only the buffer data,
offset and length that are
used. Is this the intention? In other words, does it matter what view
type is used in the
ArrayBufferView case. There is, of course, no view type for a view on
'mixed' data.
That's the intention, yep -- the overloads are just there to make it possible to pass, say, a Float32Array |f| straight to bufferData (I assume you mean bufferData, not bindBuffer), instead of having to pass |f.buffer|.  Otherwise they behave exactly the same.

Yes, sorry, I did mean bufferData.

To give a more detailed example, say I have a buffer = 'buf' which is laid out as below:

32 bytes of something (32) | vertex attributes = [ 7 floats + 3 unsigned bytes] * 24 (776) | element indices= [ 32 unsigned shorts ] (872)


where the values in parens are the offset in the buffer (ok, the 872 would be the offset to the byte beyond the end of the buffer as shown)




then

var verts = new Uint8Array(buf, 32, 744); // 744 = (7*4 +3)*24 - the number of Uint8 'elements' in the buffer.
var indxs = new Uint8Array(buf, 776, 64); // 64 = 32 * 2;


gl.bufferData(ARRAY_BUFFER, verts, STATIC_DRAW);
gl.bufferData(ELEMENT_ARRAY_BUFFER, indxs, STATIC_DRAW);

should be expected to work ok.

Sorry to belabor this point - just wanted to be clear.



Thanks, again

Alan

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