VAO¶
-
class
demosys.opengl.vao.
VAO
(name, mode=4)¶ Represents a vertex array object. A name must be provided for debug puporses. The default draw mode is
moderngl.TRIANGLES
Methods¶
-
VAO.
buffer
(buffer, buffer_format:str, attribute_names, per_instance=False)¶ Register a buffer/vbo for the VAO. This can be called multiple times. adding multiple buffers (interleaved or not)
Parameters: - buffer – The buffer object. Can be ndarray or Buffer
- buffer_format – The format of the buffer (‘f’, ‘u’, ‘i’)
Returns: The buffer object
-
VAO.
index_buffer
(buffer, index_element_size=4)¶ Set the index buffer for this VAO
Parameters: - buffer – Buffer object or ndarray
- index_element_size – Byte size of each element. 1, 2 or 4
-
VAO.
instance
(program:Program) → VertexArray¶ Obtain the moderngl.VertexArray instance for the program
Returns: moderngl.VertexArray
-
VAO.
render
(program:Program, mode=None, vertices=-1, first=0, instances=1)¶ Render the VAO.
Parameters: - program – The program to draw with
- mode – Override the draw mode (TRIANGLES etc)
- vertices – The number of vertices to transform
- first – The index of the first vertex to start with
- instances – The number of instances
-
VAO.
render_indirect
(program:Program, buffer, mode=None, count=-1, first=0)¶ 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 – (Buffer) Indirect drawing commands.
- buffer – (Buffer) Indirect drawing commands.
- mode – (int) By default
TRIANGLES
will be used. - count – (int) The number of draws.
- first – (int) The index of the first indirect draw command.
-
VAO.
transform
(program:Program, buffer:Buffer, mode=None, vertices=-1, first=0, instances=1)¶ Transform vertices. Stores the output in a single buffer.
Parameters: - program – The program
- buffer – The buffer to store the output
- mode – Draw mode (for example POINTS
- vertices – The number of vertices to transform
- first – The index of the first vertex to start with
- instances – The number of instances
-
VAO.
release
(buffer=True)¶ Destroy the vao object
Parameters: buffers – (bool) also release buffers