[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] typed array convenience
Typed arrays as specified by Khronos (https://www.khronos.org/registry/typedarray/specs/latest/
) do not have convenient methods to fill an array.
The most convenient method would be to fill a section of the array from arguments, a list and other typed arrays. Something like:
fillArray(r, i, [
x0, y0, 1, 0, 0]);
fillArguments(r, i, x0, y0, 1, 0, 0);
r[i] = x0;
r[i + 1] = y0;
r[i + 2] = 1;
r[i + 3] = 0;
r[i + 4] = 0;
i += 5
This is unfortunate because it's also the least maintainable and readable code possible.
I propose an addition to the typed array specification that introduces these methods like
- argcpy(uint dstOffset, arguments...)
- arrcpy(uint dstOffset, Array|TypedArrayView someArray)
- memcpy(uint dstByteOffset, TypedArray[View] origin, uint srcByteOffset, uint srcByteCount)
The name or the semantic of the methods doesn't matter to me, as long as they facilitate fast, efficient and convenient filling of typed arrays.
It is quite often for tasks todo with tessellation, subdivision, geometry generation etc. to have to write code like that.
Description: PNG image