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.
IndexedVertexDomain
(attribute_usages, index_gl_type=5125)¶Management of a set of indexed vertex lists.
Construction of an indexed vertex domain is usually done with the create_indexed_domain function.
create
(count, index_count)¶Create an IndexedVertexList
in this domain.
count (int) – Number of vertices to create
index_count – Number of indices to create
draw
(mode, vertex_list=None)¶Draw vertices in the domain.
If vertex_list is not specified, all vertices in the domain are drawn. This is the most efficient way to render primitives.
If vertex_list specifies a VertexList
, only primitives in
that list will be drawn.
mode (int) – OpenGL drawing mode, e.g. GL_POINTS
, GL_LINES
, etc.
vertex_list (IndexedVertexList) – Vertex list to draw, or None
for all lists in this domain.
get_index_region
(start, count)¶Get a region of the index buffer.
start (int) – Start of the region to map.
count (int) – Number of indices to map.
Array of int
IndexedVertexList
(domain, start, count, index_start, index_count)¶A list of vertices within an IndexedVertexDomain
that are
indexed. Use IndexedVertexDomain.create()
to construct this list.
delete
()¶Delete this group.
draw
(mode)¶Draw this vertex list in the given OpenGL mode.
mode (int) – OpenGL drawing mode, e.g. GL_POINTS
, GL_LINES
, etc.
migrate
(domain)¶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).
domain (IndexedVertexDomain) – Indexed domain to migrate this vertex list to.
resize
(count, index_count)¶Resize this group.
count (int) – New number of vertices in the list.
index_count (int) – New number of indices in the list.
indices
¶Array of index data.
VertexDomain
(attribute_usages)¶Management of a set of vertex lists.
Construction of a vertex domain is usually done with the
create_domain()
function.
create
(count)¶Create a VertexList
in this domain.
count (int) – Number of vertices to create.
draw
(mode, vertex_list=None)¶Draw vertices in the domain.
If vertex_list is not specified, all vertices in the domain are drawn. This is the most efficient way to render primitives.
If vertex_list specifies a VertexList
, only primitives in
that list will be drawn.
mode (int) – OpenGL drawing mode, e.g. GL_POINTS
, GL_LINES
, etc.
vertex_list (VertexList) – Vertex list to draw, or None
for all lists in this domain.
VertexList
(domain, start, count)¶A list of vertices within a VertexDomain
. Use
VertexDomain.create()
to construct this list.
delete
()¶Delete this group.
draw
(mode)¶Draw this vertex list in the given OpenGL mode.
mode (int) – OpenGL drawing mode, e.g. GL_POINTS
, GL_LINES
, etc.
get_domain
()¶Get the domain this vertex list belongs to.
get_size
()¶Get the number of vertices in the list.
int
migrate
(domain)¶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).
domain (VertexDomain) – Domain to migrate this vertex list to.
resize
(count)¶Resize this group.
count (int) – New number of vertices in the list.
colors
¶Array of color data.
edge_flags
¶Array of edge flag data.
fog_coords
¶Array of fog coordinate data.
multi_tex_coords
¶Multi-array texture coordinate data.
normals
¶Array of normal vector data.
secondary_colors
¶Array of secondary color data.
tex_coords
¶Array of texture coordinate data.
vertices
¶Array of vertex coordinate data.
create_attribute_usage
(fmt)¶Create an attribute and usage pair from a format string. The format string is as documented in pyglet.graphics.vertexattribute, with the addition of an optional usage component:
usage ::= attribute ( '/' ('static' | 'dynamic' | 'stream' | 'none') )?
If the usage is not given it defaults to ‘dynamic’. The usage corresponds
to the OpenGL VBO usage hint, and for static
also indicates a
preference for interleaved arrays. If none
is specified a buffer
object is not created, and vertex data is stored in system memory.
Some examples:
v3f/stream
3D vertex position using floats, for stream usage
c4b/static
4-byte color attribute, for static usage
attribute, usage
create_domain
(*attribute_usage_formats)¶Create a vertex domain covering the given attribute usage formats.
See documentation for create_attribute_usage()
and
pyglet.graphics.vertexattribute.create_attribute()
for the grammar
of these format strings.
create_indexed_domain
(*attribute_usage_formats)¶Create an indexed vertex domain covering the given attribute usage
formats. See documentation for create_attribute_usage
and
pyglet.graphics.vertexattribute.create_attribute()
for the grammar
of these format strings.