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.

__init__(program, attribute_meta, index_gl_type=5125)
create(count, index_count)

Create an IndexedVertexList in this domain.

Parameters:
countint

Number of vertices to create

index_count

Number of indices to create

draw(mode)

Draw all vertices in the domain.

All vertices in the domain are drawn at once. This is the most efficient way to render primitives.

Parameters:
modeint

OpenGL drawing mode, e.g. GL_POINTS, GL_LINES, etc.

draw_subset(mode, vertex_list)

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:
modeint

OpenGL drawing mode, e.g. GL_POINTS, GL_LINES, etc.

vertex_listIndexedVertexList

Vertex list to draw.

get_index_region(start, count)

Get a data from a region of the index buffer.

Parameters:
startint

Start of the region to map.

countint

Number of indices to map.

Return type:

Array of int

safe_index_alloc(count)

Allocate indices, resizing the buffers if necessary.

safe_index_realloc(start, count, new_count)

Reallocate indices, resizing the buffers if necessary.

set_index_region(start, count, data)
class IndexedVertexList

A list of vertices within an IndexedVertexDomain that are indexed. Use IndexedVertexDomain.create() to construct this list.

__init__(domain, start, count, index_start, index_count)
delete()

Delete this group.

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).

Parameters:
domainIndexedVertexDomain

Indexed domain to migrate this vertex list to.

resize(count, index_count)

Resize this group.

Parameters:
countint

New number of vertices in the list.

index_countint

New number of indices in the list.

property indices

Array of index data.

class VertexDomain

Management of a set of vertex lists.

Construction of a vertex domain is usually done with the create_domain() function.

__init__(program, attribute_meta)
create(count, index_count=None)

Create a VertexList in this domain.

Parameters:
countint

Number of vertices to create.

index_count: None

Ignored for non indexed VertexDomains

Return type:

VertexList

draw(mode)

Draw all vertices in the domain.

All vertices in the domain are drawn at once. This is the most efficient way to render primitives.

Parameters:
modeint

OpenGL drawing mode, e.g. GL_POINTS, GL_LINES, etc.

draw_subset(mode, vertex_list)

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:
modeint

OpenGL drawing mode, e.g. GL_POINTS, GL_LINES, etc.

vertex_listVertexList

Vertex list to draw.

safe_alloc(count)

Allocate vertices, resizing the buffers if necessary.

safe_realloc(start, count, new_count)

Reallocate vertices, resizing the buffers if necessary.

property is_empty
class VertexList

A list of vertices within a VertexDomain. Use VertexDomain.create() to construct this list.

__init__(domain, start, count)
delete()

Delete this group.

draw(mode)

Draw this vertex list in the given OpenGL mode.

Parameters:
modeint

OpenGL drawing mode, e.g. GL_POINTS, GL_LINES, etc.

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).

Parameters:
domainVertexDomain

Domain to migrate this vertex list to.

resize(count, index_count=None)

Resize this group.

Parameters:
countint

New number of vertices in the list.

index_count: None

Ignored for non indexed VertexDomains

set_attribute_data(name, data)