multi-index-elements - Factor Documentation (original) (raw)
Class description
Objects of this tuple class can be passed as the indexes slot of a non-instanced render-set to instruct render to assemble primitives from the active vertex-array by using multiple arrays of indexes in CPU or GPU memory.
• | The buffer slot contains either a buffer object to read indexes from, or f to read from CPU memory. |
---|---|
• | The ptrs slot contains either a void*-array of pointers to the starts of index data, or a pointer-sized ulong-array of offsets into buffer. |
• | The counts slot contains a uint-array containing the number of indexes to read from each pointer or offset in ptrs. |
• | The index-type slot contains an index-type value specifying whether the arrays consist of ubyte-indexes, ushort-indexes, or uint-indexes. |
See also
index-elements, index-range, multi-index-range
Definition
USING: gpu.buffers
specialized-arrays.instances.alien.c-types.uint ;
TUPLE: multi-index-elements
{ buffer maybe{ buffer } read-only initial: f }
{ ptrs read-only }
{ counts uint-array read-only initial: uint-array{ } }
{ index-type index-type read-only initial: ubyte-indexes } ;
Methods
USING: accessors combinators gpu.render gpu.render.private
kernel opengl.gl sequences ;
M: multi-index-elements render-vertex-indexes
[ gl-primitive-mode ] [
{
[ counts>> ]
[ index-type>> gl-index-type ]
[ ptrs>> dup length ]
[ buffer>> ]
} cleave
] bi* GL_ELEMENT_ARRAY_BUFFER swap [ handle>> ] [ 0 ] if*
glBindBuffer glMultiDrawElements ;