Class pyglet.graphics.vertexbuffer.VertexArray

  AbstractBuffer --+
                   |
AbstractMappable --+
                   |
                  VertexArray

A ctypes implementation of a vertex array.

Many of the methods on this class are effectively no-op's, such as bind, unbind, map, unmap and delete; they exist in order to present a consistent interface with VertexBufferObject.

This buffer type is also mappable, and so get_region can be used.

Methods

  __init__(self, size)
  bind(self)
Bind this buffer to its OpenGL target.
  unbind(self)
Reset the buffer's OpenGL target.
  set_data(self, data)
Set the entire contents of the buffer.
  set_data_region(self, data, start, length)
Set part of the buffer contents.
POINTER(ctypes.c_ubyte) map(self, invalidate=False)
Map the entire buffer into system memory.
  unmap(self)
Unmap a previously mapped memory block.
AbstractBufferRegion get_region(self, start, size, ptr_type)
Map a region of the buffer into a ctypes array of the desired type.
  delete(self)
Delete this buffer, reducing system resource usage.
  resize(self, size)
Resize the buffer to a new size.

Instance Variables

int ptr = 0
Memory offset of the buffer, as used by the glVertexPointer family of functions
(Inherited from pyglet.graphics.vertexbuffer.AbstractBuffer)
int size = 0
Size of buffer, in bytes
(Inherited from pyglet.graphics.vertexbuffer.AbstractBuffer)
int target
OpenGL buffer target, for example GL_ARRAY_BUFFER
(Inherited from pyglet.graphics.vertexbuffer.AbstractBuffer)
int usage
OpenGL buffer usage, for example GL_DYNAMIC_DRAW
(Inherited from pyglet.graphics.vertexbuffer.AbstractBuffer)

Method Details

bind

bind(self)
Bind this buffer to its OpenGL target.
Overrides:
AbstractBuffer.bind

unbind

unbind(self)
Reset the buffer's OpenGL target.
Overrides:
AbstractBuffer.unbind

set_data

set_data(self, data)
Set the entire contents of the buffer.
Overrides:
AbstractBuffer.set_data

set_data_region

set_data_region(self, data, start, length)
Set part of the buffer contents.
Overrides:
AbstractBuffer.set_data_region

map

map(self, invalidate=False)

Map the entire buffer into system memory.

The mapped region must be subsequently unmapped with unmap before performing any other operations on the buffer.

Returns:
POINTER(ctypes.c_ubyte): Pointer to the mapped block in memory
Overrides:
AbstractBuffer.map

unmap

unmap(self)
Unmap a previously mapped memory block.
Overrides:
AbstractBuffer.unmap

get_region

get_region(self, start, size, ptr_type)

Map a region of the buffer into a ctypes array of the desired type. This region does not need to be unmapped, but will become invalid if the buffer is resized.

Note that although a pointer type is required, an array is mapped. For example:

get_region(0, ctypes.sizeof(c_int) * 20, ctypes.POINTER(c_int * 20))

will map bytes 0 to 80 of the buffer to an array of 20 ints.

Changes to the array may not be recognised until the region's AbstractBufferRegion.invalidate method is called.

Returns: AbstractBufferRegion
Overrides:
AbstractMappable.get_region

delete

delete(self)
Delete this buffer, reducing system resource usage.
Overrides:
AbstractBuffer.delete

resize

resize(self, size)
Resize the buffer to a new size.
Overrides:
AbstractBuffer.resize