class moderngl_window.opengl.vao.VAO(name: str = '', mode: int = 4)

  Represents a vertex array object.

  This is a wrapper class over `moderngl.VertexArray` to make interactions with programs/shaders simpler. Named buffers are added corresponding with attribute names in a vertex shader. When rendering the VAO an internal `moderngl.VertextArray` is created automatically mapping the named buffers compatible with the supplied program. This program is cached internally.

  The shader program doesn’t need to use all the buffers registered in this wrapper. When a subset is used only the used buffers are mapped and the appropriate padding is calculated when interleaved data is used.

  You are not required to use this class, but most methods in the system creating vertexbuffers will return this type. You can obtain a single `moderngl.VertexBuffer` instance by calling `VAO.instance()` method if you prefer to work directly on moderngl instances.

  Example:

      # Separate buffers
      vao = VAO(name="test", mode=moderngl.POINTS)
      vao.buffer(positions, '3f', ['in_position'])
      vao.buffer(velocities, '3f', ['in_velocities'])

      # Interleaved
      vao = VAO(name="test", mode=moderngl.POINTS)
      vao.buffer(interleaved_data, '3f 3f', ['in_position', 'in_velocities'])

      # GLSL vertex shader in attributes
      in vec3 in_position;
      in vec3 in_velocities;

  buffer(buffer: Buffer | ndarray[tuple[Any, ...], dtype[Any]] | bytes, buffer_format: str, attribute_names: list[str] | str) → Buffer

    Register a buffer/vbo for the VAO. This can be called multiple times. adding multiple buffers (interleaved or not).

    Parameters:

      - buffer – The buffer data. Can be `numpy.array`, `moderngl.Buffer` or `bytes`.

      - buffer_format (str) – The format of the buffer. (eg. `3f 3f` for interleaved positions and normals).

      - attribute_names – A list of attribute names this buffer should map to.

    Returns:

      The `moderngl.Buffer` instance object. This is handy when providing `bytes` and `numpy.array`.

  property ctx: Context

    The active moderngl context

    Type:

      moderngl.Context

  get_buffer_by_name(name: str) → BufferInfo | None

    Get the BufferInfo associated with a specific attribute name

    If no buffer is associated with the name None will be returned.

    Parameters:

      name (str) – Name of the mapped attribute

    Returns:

      BufferInfo instance

    Return type:

      BufferInfo

  index_buffer(buffer: Buffer | ndarray[tuple[Any, ...], dtype[Any]] | bytes, index_element_size: int = 4) → None

    Set the index buffer for this VAO.

    Parameters:

      buffer – `moderngl.Buffer`, `numpy.array` or `bytes`

    Keyword Arguments:

      index_element_size (int) – Byte size of each element. 1, 2 or 4

  instance(program: Program) → VertexArray

    Obtain the `moderngl.VertexArray` instance for the program.

    The instance is only created once and cached internally.

    Parameters:

      program (moderngl.Program) – The program

    Returns:

      instance

    Return type:

      `moderngl.VertexArray`

  release(buffer: bool = True) → None

    Destroy all internally cached vaos and release all buffers.

    Keyword Arguments:

      buffers (bool) – also release buffers

  render(program: Program, mode: int | None = None, vertices: int = -1, first: int = 0, instances: int = 1) → None

    Render the VAO.

    An internal `moderngl.VertexBuffer` with compatible buffer bindings is automatically created on the fly and cached internally.

    Parameters:

      program – The `moderngl.Program`

    Keyword Arguments:

      - mode – Override the draw mode (`TRIANGLES` etc)

      - vertices (int) – The number of vertices to transform

      - first (int) – The index of the first vertex to start with

      - instances (int) – The number of instances

  render_indirect(program: Program, buffer: Buffer, mode: int | None = None, count: int = -1, *, first: int = 0) → None

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

    The draw commands are 5 integers: (count, instanceCount, firstIndex, baseVertex, baseInstance).

    Parameters:

      - program – The `moderngl.Program`

      - buffer – The `moderngl.Buffer` containing indirect draw commands

    Keyword Arguments:

      - mode (int) – By default `TRIANGLES` will be used.

      - count (int) – The number of draws.

      - first (int) – The index of the first indirect draw command.

  transform(program: Program, buffer: Buffer, mode: int | None = None, vertices: int = -1, first: int = 0, instances: int = 1) → None

    Transform vertices. Stores the output in a single buffer.

    Parameters:

      - program – The `moderngl.Program`

      - buffer – The `moderngl.buffer` to store the output

    Keyword Arguments:

      - mode – Draw mode (for example `moderngl.POINTS`)

      - vertices (int) – The number of vertices to transform

      - first (int) – The index of the first vertex to start with

      - instances (int) – The number of instances