pyglet.graphics.vertexbuffer

OpenGL Buffer Objects.

BufferObject and a BackedBufferObject are provided. The first is a lightweight abstraction over an OpenGL buffer, as created with glGenBuffers. The backed buffer object is similar, but provides a full mirror of the data in CPU memory. This allows for delayed uploading of changes to GPU memory, which can improve performance is some cases.

class AbstractBuffer

Abstract buffer of byte data.

Class Variables:
  • size (int) – Size of buffer, in bytes

  • ptr (int) – Memory offset of the buffer, as used by the glVertexPointer family of functions

ptr: int = 0
size: int = 0
class AttributeBufferObject

A backed buffer used for Shader Program attributes.

class BackedBufferObject

A buffer with system-memory backed store.

Updates to the data via set_data and set_data_region will be held in system memory until commit is called. The advantage is that fewer OpenGL calls are needed, which can increase performance at the expense of system memory.

count: int
ctype: Type[_SimpleCData]
data: Type[_SimpleCData]
data_ptr: int
stride: int
class BufferObject

Lightweight representation of an OpenGL Buffer Object.

The data in the buffer is not replicated in any system memory (unless it is done so by the video driver). While this can reduce system memory usage, performing multiple small updates to the buffer can be relatively slow. The target of the buffer is GL_ARRAY_BUFFER internally to avoid accidentally overriding other states when altering the buffer contents. The intended target can be set when binding the buffer.

id: int
usage: int
class IndexedBufferObject

A backed buffer used for indices.

class PersistentBufferObject

A persistently mapped buffer.

Available in OpenGL 4.3+ contexts. Persistently mapped buffers are mapped one time on creation, and can be updated at any time without the need to map or unmap.

__init__(size, attribute, vao)
bind(target=34962)

Bind this buffer to an OpenGL target.

get_region(start, count)
invalidate()
invalidate_region(start, count)
map_range(start, size, ptr_type, flags=2)
resize(size)

Resize the buffer to a new size.

Parameters:

size – New size of the buffer, in bytes

set_region(start, count, data)
sub_data()
unbind()

Reset the buffer’s OpenGL target.