OpenGL.arrays.vbo

VertexBufferObject helper class
Basic usage:
my_data = numpy.array( data, 'f') my_vbo = vbo.VBO( my_data ) ... my_vbo.bind() try: ... glVertexPointer( my_vbo, ... ) ... glNormalPointer( my_vbo + 12, ... ) finally: my_vbo.unbind()
or
with my_vbo: ... glVertexPointer( my_vbo, ... ) ... glNormalPointer( my_vbo + 12, ... )
See the OpenGLContext shader tutorials for a gentle introduction on the usage of VBO objects:
This implementation will choose either the ARB or Core (OpenGL 1.5) implementation of the VBO functions.

Functions

_cleaner( vbo )
Construct a mapped-array cleaner function to unmap vbo.target
mapVBO( vbo , access = 35002 )
Map the given buffer into a numpy array...
This should be considered an *experimental* API, it is not guaranteed to be available in future revisions of this library!
Simplification to use ctypes cast from comment by 'sashimi' on my blog...

Classes

class Implementation( object ):
Abstraction point for the various implementations that can be used
class VBO( object ):
Instances can be passed into array-handling routines
You can check for whether VBOs are supported by accessing the implementation:
if bool(vbo.get_implementation()): # vbo version of code else: # fallback version of code
implementation
__init__( self , data , usage = 'GL_DYNAMIC_DRAW' , target = 'GL_ARRAY_BUFFER' , size = None )
Initialize the VBO object
data
PyOpenGL-compatible array-data structure, numpy arrays, ctypes arrays, etc.
usage
OpenGL usage constant describing expected data-flow patterns (this is a hint to the GL about where/how to cache the data)
GL_STATIC_DRAW_ARB GL_STATIC_READ_ARB GL_STATIC_COPY_ARB GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_READ_ARB GL_DYNAMIC_COPY_ARB GL_STREAM_DRAW_ARB GL_STREAM_READ_ARB GL_STREAM_COPY_ARB
DRAW constants suggest to the card that the data will be primarily used to draw on the card. READ that the data will be read back into the GL. COPY means that the data will be used both for DRAW and READ operations.
STATIC suggests that the data will only be written once (or a small number of times). DYNAMIC suggests that the data will be used a small number of times before being discarded. STREAM suggests that the data will be updated approximately every time that it is used (that is, it will likely only be used once).
target
VBO target to which to bind (array or indices)
GL_ARRAY_BUFFER
array-data binding
GL_ELEMENT_ARRAY_BUFFER
index-data binding
GL_UNIFORM_BUFFER
used to pass mid-size arrays of data packed into a buffer
GL_TEXTURE_BUFFER
used to pass large arrays of data as a pseudo-texture
GL_TRANSFORM_FEEDBACK_BUFFER
used to receive transformed vertices for processing
size
if not provided, will use arrayByteCount to determine the size of the data-array, thus this value (number of bytes) is required when using opaque data-structures, (such as ctypes pointers) as the array data-source.
class VBOHandler( FormatHandler ):
Handles VBO instances passed in as array data
This FormatHandler is registered with PyOpenGL on import of this module to provide handling of VBO objects as array data-sources
class VBOOffset( object ):
Offset into a VBO instance
This class is normally instantiated by doing a my_vbo + int operation, it can be passed to VBO requiring operations and will generate the appropriate integer offset value to be passed in.
class VBOOffsetHandler( VBOHandler ):
Handles VBOOffset instances passed in as array data
Registered on module import to provide support for VBOOffset instances as sources for array data.

AltStyle によって変換されたページ (->オリジナル) /