Manage a collection of vertex lists for batched rendering.
Vertex lists are added to a Batch using the add and add_indexed methods. An optional group can be specified along with the vertex list, which gives the OpenGL state required for its rendering. Vertex lists with shared mode and group are allocated into adjacent areas of memory and sent to the graphics card in a single operation.
Call VertexList.delete to remove a vertex list from the batch.
Constructor:
Create a graphics batch.
Methods:
add(count, mode, group, *data) Add a vertex list to the batch. add_indexed(count, mode, group, indices, *data) Add an indexed vertex list to the batch. draw() Draw the batch. draw_subset(vertex_lists) Draw only some vertex lists in the batch. invalidate() Force the batch to update the draw list. migrate(vertex_list, mode, group, batch) Migrate a vertex list to another batch and/or group.
Add a vertex list to the batch.
Parameters: |
|
---|---|
Return type: | VertexList |
Add an indexed vertex list to the batch.
Parameters: |
|
---|---|
Return type: | IndexedVertexList |
Draw the batch.
Draw only some vertex lists in the batch.
The use of this method is highly discouraged, as it is quite inefficient. Usually an application can be redesigned so that batches can always be drawn in their entirety, using draw.
The given vertex lists must belong to this batch; behaviour is undefined if this condition is not met.
Parameters: | vertex_lists (sequence of VertexList or IndexedVertexList) – Vertex lists to draw. |
---|
Force the batch to update the draw list.
This method can be used to force the batch to re-compute the draw list when the ordering of groups has changed.
Note
Since pyglet 1.2
Migrate a vertex list to another batch and/or group.
vertex_list and mode together identify the vertex list to migrate. group and batch are new owners of the vertex list after migration.
The results are undefined if mode is not correct or if vertex_list does not belong to this batch (they are not checked and will not necessarily throw an exception immediately).
batch can remain unchanged if only a group change is desired.
Parameters: |
|
---|