VertexArray

Context.simple_vertex_array(program, buffer, attributes) → VertexArray

Create a VertexArray.

This is an alias for:

format = detect_format(program, attributes) vertex_array(program, [(buffer, format, attributes)])
Parameters:
  • program (Program) – The program used by render and transform.
  • buffer (Buffer) – The buffer.
  • attributes (list) – A list of attribute names.
Returns:

vertex array

Return type:

VertexArray

Context.vertex_array(program, content, index_buffer=None) → VertexArray

Create a VertexArray.

Parameters:
  • program (Program) – The program used by render and transform.
  • content (list) – A list of (buffer, format, attributes).
  • index_buffer (Buffer) – An index buffer.
Returns:

vertex array

Return type:

VertexArray

class VertexArray

A VertexArray object is an OpenGL object that stores all of the state needed to supply vertex data. It stores the format of the vertex data as well as the Buffer objects providing the vertex data arrays.

In ModernGL, the VertexArray object also stores a reference for a Program object, and some Subroutine information.

A VertexArray object cannot be instantiated directly, it requires a context. Use Context.vertex_array() or Context.simple_vertex_array() to create one.

render(mode=TRIANGLES, vertices=-1, first=0, instances=1)

The render primitive (mode) must be the same as the input primitive of the GeometryShader.

Parameters:
  • mode – By default TRIANGLES will be used.
  • vertices – The number of vertices to transform.
Keyword Arguments:
 
  • first – The index of the first vertex to start with.
  • instances – The number of instances.
transform(buf, mode=POINTS, vertices=-1, *, first=0, instances=1)

Transform vertices. Stores the output in a single buffer. The transform primitive (mode) must be the same as the input primitive of the GeometryShader.

Parameters:
  • buffer – The buffer to store the output.
  • mode – By default TRIANGLES will be used.
  • vertices – The number of vertices to transform.
Keyword Arguments:
 
  • first – The index of the first vertex to start with.
  • instances – The number of instances.
program

Program – The program assinged to the VertexArray. The program used when rendering or transforming primitives.

attributes

VertexArrayAttributeMap – Individual vertex attributes. Use the VertexArrayAttribute.bind() method to assign vertex attributes to buffers.

index_buffer

Buffer – The index buffer if the index_buffer is set, otherwise None.

vertices

int – The number of vertices detected. This is the minimum of the number of vertices possible per Buffer. The size of the index_buffer determines the number of vertices. Per instance vertex attributes does not affect this number.

subroutines

tuple – The subroutines assinged to the VertexArray. The subroutines used when rendering or transforming primitives.

Classes: