pyglet.graphics.vertexdomain
Manage related vertex attributes within a single vertex domain.
A vertex “domain” consists of a set of attribute descriptions that together describe the layout of one or more vertex buffers which are used together to specify the vertices in a primitive. Additionally, the domain manages the buffers used to store the data and will resize them as necessary to accommodate new vertices.
Domains can optionally be indexed, in which case they also manage a buffer containing vertex indices. This buffer is grown separately and has no size relation to the attribute buffers.
Applications can create vertices (and optionally, indices) within a domain
with the VertexDomain.create()
method. This returns a
VertexList
representing the list of vertices created. The vertex
attribute data within the group can be modified, and the changes will be made
to the underlying buffers automatically.
The entire domain can be efficiently drawn in one step with the
VertexDomain.draw()
method, assuming all the vertices comprise
primitives of the same OpenGL primitive mode.
- class IndexedVertexDomain
Management of a set of indexed vertex lists.
Construction of an indexed vertex domain is usually done with the
create_domain()
function.- create( ) IndexedVertexList
Create an
IndexedVertexList
in this domain.- Parameters:
- Return type:
- draw(mode: int) None
Draw all vertices in the domain.
All vertices in the domain are drawn at once. This is the most efficient way to render primitives.
- draw_subset(
- mode: int,
- vertex_list: IndexedVertexList,
Draw a specific IndexedVertexList in the domain.
The vertex_list parameter specifies a
IndexedVertexList
to draw. Only primitives in that list will be drawn.- Parameters:
mode (
int
) – OpenGL drawing mode, e.g.GL_POINTS
,GL_LINES
, etc.vertex_list (
IndexedVertexList
) – Vertex list to draw.
- Return type:
- safe_index_alloc(count: int) int
Allocate indices, resizing the buffers if necessary.
- Return type:
- safe_index_realloc(start: int, count: int, new_count: int) int
Reallocate indices, resizing the buffers if necessary.
- Return type:
-
index_buffer:
IndexedBufferObject
- class IndexedVertexList
A list of vertices within an
IndexedVertexDomain
that are indexed.Use
IndexedVertexDomain.create()
to construct this list.- __init__(
- domain: IndexedVertexDomain,
- start: int,
- count: int,
- index_start: int,
- index_count: int,
- migrate(
- domain: IndexedVertexDomain | InstancedIndexedVertexDomain,
Move this group from its current indexed domain and add to the specified one.
Attributes on domains must match. (In practice, used to change parent state of some vertices).
- Parameters:
domain (
IndexedVertexDomain
|InstancedIndexedVertexDomain
) – Indexed domain to migrate this vertex list to.- Return type:
- set_instance_source(
- domain: IndexedVertexDomain | InstancedIndexedVertexDomain,
- instance_attributes: Sequence[str],
- Return type:
- class InstancedIndexedVertexDomain
Management of a set of indexed vertex lists.
Construction of an indexed vertex domain is usually done with the
create_domain()
function.- create( ) IndexedVertexList
Create an
IndexedVertexList
in this domain.- Parameters:
- Return type:
- draw(mode: int) None
Draw all vertices in the domain.
All vertices in the domain are drawn at once. This is the most efficient way to render primitives.
- draw_subset(
- mode: int,
- vertex_list: IndexedVertexList,
Draw a specific IndexedVertexList in the domain.
The
vertex_list
parameter specifies aIndexedVertexList
to draw. Only primitives in that list will be drawn.- Parameters:
mode (
int
) – OpenGL drawing mode, e.g.GL_POINTS
,GL_LINES
, etc.vertex_list (
IndexedVertexList
) – Vertex list to draw.
- Return type:
- class InstancedVertexDomain
-
- draw(mode: int) None
Draw all vertices in the domain.
All vertices in the domain are drawn at once. This is the most efficient way to render primitives.
- draw_subset(
- mode: int,
- vertex_list: VertexList,
Draw a specific VertexList in the domain.
The vertex_list parameter specifies a
VertexList
to draw. Only primitives in that list will be drawn.- Parameters:
mode (
int
) – OpenGL drawing mode, e.g.GL_POINTS
,GL_LINES
, etc.vertex_list (
VertexList
) – Vertex list to draw.
- Return type:
- class VertexDomain
Management of a set of vertex lists.
Construction of a vertex domain is usually done with the
create_domain()
function.- create( ) VertexList
Create a
VertexList
in this domain.- Parameters:
- Return type:
- draw(mode: int) None
Draw all vertices in the domain.
All vertices in the domain are drawn at once. This is the most efficient way to render primitives.
- draw_subset(
- mode: int,
- vertex_list: VertexList,
Draw a specific VertexList in the domain.
The vertex_list parameter specifies a
VertexList
to draw. Only primitives in that list will be drawn.- Parameters:
mode (
int
) – OpenGL drawing mode, e.g.GL_POINTS
,GL_LINES
, etc.vertex_list (
VertexList
) – Vertex list to draw.
- Return type:
- safe_realloc(start: int, count: int, new_count: int) int
Reallocate vertices, resizing the buffers if necessary.
- Return type:
-
attrib_name_buffers:
dict
[str
,AttributeBufferObject
]
-
buffer_attributes:
list
[tuple
[AttributeBufferObject
,Attribute
]]
-
vao:
VertexArray
- class VertexInstance
- __init__(
- vertex_list: VertexList | IndexedVertexList,
- instance_id: int,
- start: int,
- property domain: InstancedVertexDomain | InstancedIndexedVertexDomain
- class VertexList
A list of vertices within a
VertexDomain
.Use
VertexDomain.create()
to construct this list.- __init__(
- domain: VertexDomain,
- start: int,
- count: int,
- add_instance(
- **kwargs: Any,
- Return type:
- delete_instance(
- instance: VertexInstance,
- Return type:
- migrate(
- domain: VertexDomain | InstancedVertexDomain,
Move this group from its current domain and add to the specified one.
Attributes on domains must match. (In practice, used to change parent state of some vertices).
- Parameters:
domain (
VertexDomain
|InstancedVertexDomain
) – Domain to migrate this vertex list to.- Return type:
- set_instance_source(
- domain: InstancedVertexDomain,
- instance_attributes: Sequence[str],
- Return type:
-
domain:
VertexDomain
|InstancedVertexDomain