more Data operations
So I was recently using the Data API to implement the glTF format and while I was asking questions slime mentioned he wasn't sure what methods he wanted to add so I figured I would write down what would be handy for me in particular.
a way to allocate a chunk of generic data, in bytes. I don't really care what is inside the chunk, because I'm going to use it with the FFI anyways and I can memset/memcpy myself.
a way to present a "slice" of data to function that wants a Data object. A slice would be the same as its parent Data, except that it can start in the middle of its parent and end sooner than its parent does. glTF is a great example of how this would be practically useful: images, vertex data, etc are all embedded in the same binary file, and it would be much cheaper to load everything, then pass around offsets, then to work around the fact that 1 buffer == 1 "file" as it is now.
I don't think I need a
realloc()equivalent, although it seems like somebody might. /shrug
This is only semi-related to Data, but while glTF supports interleaved data most exporters prefer
X X X Y Y Y Z Z Z
X Y Z X Y Z X Y Z
mesh:setVertices() can only understand format 2 here, which means I need to make a new buffer and manually translate it to support format 1.
and that's it~ I've only implemented meshes/mesh attributes, which leaves out animations/vertex skinning etc. but I still think this is a good real-world example as is