[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] ArrayBuffer, Concatenation and String-Array Conversion, a proposal
See comments below:
On 10/05/2010 02:04 PM, Samuel Kleiner wrote:
If you have a vertex array, for example, this will be at the very least
a sequence of floating point numbers. You may also have data in some
other format - eg colors as bytes.
I think it will be.
in the 'real world' a floating point number to represent a vertex or a
texture coordinate probably represents maybe 6 or 7 characters + at
least one separating character, so probably at least 8 characters (which
may be 2 bytes) per fp.
You can send exactly the same data with 4 bytes per FP and 1 byte per
color using the (moz)'responseArrayBuffer' or even by packing binary
into an ASCII response
In many applications the vertex data doesn't change. It makes sense to
cache such a file on the server and allow the browser to cache it as
well. I've already tried this and it works extremely well.
If people were to choose to signed vertex (or animation) data as large
blocks of strings then there are already mechanisms for handling those.
Also, if you parse a very large JSON object surely you end up with all
the data required for the object allocated. It seems to me that a much
better practice is to separate out that data which will be passed into
the GL and keep as few copies of that in memory as possible. By making
an ArrayBuffer a cacheable item it can be stored on the server, or in
the local cache, passed to the GL and the in-memory client copy deleted
because its no longer required, thus reducing the memory footprint.
So JS functions which loop over the string, calling charCodeAt() for each character, give you a reasonable solution. I'm not sure why that would not be a reasonable solution here as well. I'm not sure your example would be commonly used. Assuming we get the ability to read an ArrayBuffer from XHR, the better way to load large vertex data will be to load the binary data directly.
You are currently subscribed to email@example.com.
To unsubscribe, send an email to firstname.lastname@example.org with
the following command in the body of your email: