pyglet.graphics.instance
VertexInstance provides an object handle for one independently managed
instance. For array-oriented workloads, InstanceCollection manages the
entire contiguous instance range without allocating a Python object for every
item. See Instanced Rendering for selection guidance and examples.
- class InstanceCollection( ) None
Manage contiguous instance data without per-instance Python objects.
Create collections with
vertex_list.create_instance_collection.Create an instance collection.
- Parameters:
bucket_ref (
ReferenceType[InstanceBucket]) – Weak reference to the instance bucket that owns the collection.capacity (
int) – Number of instance slots reserved in the stream.count (
int) – Number of active instances submitted by draw calls.
- insert( ) None
Insert instance slots, shifting following data to the right.
This is convenient for occasional structural edits, but shifting large ranges is more expensive than replacing attributes with
set().
- remove(start: int, count: int = 1) None
Remove active slots while retaining the collection’s capacity.
Following instance data is shifted left to keep the active range contiguous.
- reserve(capacity: int) None
Reserve storage without changing the active instance count.
Existing data and the current draw count are preserved. Requests no larger than the current capacity do nothing.
- set( ) None
Update one or more attributes over a contiguous active range.
Attribute values are flattened sequences sized for
countrows. Attributes not supplied are left unchanged.