Class pyglet.graphics.vertexbuffer.VertexBufferObject

AbstractBuffer --+
                 |
                VertexBufferObject
Known Subclasses:
MappableVertexBufferObject

Lightweight representation of an OpenGL VBO.

The data in the buffer is not replicated in any system memory (unless it is done so by the video driver). While this can improve memory usage and possibly performance, updates to the buffer are relatively slow.

This class does not implement AbstractMappable, and so has no get_region method. See MappableVertexBufferObject for a VBO class that does implement get_region.

Methods

  __init__(self, size, target, usage)
  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.
  __del__(self)
  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

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