I’m working with OpenGL, and using buffers to store vertex data in video memory. For effiency / convenience, I’m allocating big chunks of video memory, and then reserving chunks as I need them. There are three data structures I’m using:
- The buffer itself.
- A “chunk” of the buffer – a contiguous block of memory within thebuffer.
- A “skippy chunk” within a regular chunk. OpenGL lets you interlace your vertex attributes, and these “skippy chunks” let you describe how different attributes are woven together within a chunk / buffer.
Now I reckon that “Buffer” is a good name for that first data structure, but what are the other two called? I assume there’s a technical term, but I don’t know it, and don’t know how to find it…
And here’s an example memory layout, to back up my sketchy description (this buffer has three types of attributes: colors, vertices, and normals):
+--+--+--+--+--+--+--+--+--+--+--+
|c1|c2|c3|c4|c5|v1|n1|v2|n2|v3|n3|
+--+--+--+--+--+--+--+--+--+--+--+
|------------Buffer--------------| <- Buffer Class
|----chunk1----|------chunk2-----| <- "Chunk" classes
|--| |--| |--| <- "Skippy Chunk" class (vertices)
|--| |--| |--| <- "Skippy Chunk" class (normals)
Thanks in advance!
The part with your “skippy chunks” resembles interleaved arrays.
It is quite common to mix such data (vertices, texture coordinates, normals, colors, …) in a chunk of linear memory (“buffer”) and access it using base addresses, offsets, and strides.