Module BGL :: Class Buffer
[frames | no frames]

Class Buffer


The Buffer object is simply a block of memory that is delineated and initialized by the user. Many OpenGL functions return data to a C-style pointer, however, because this is not possible in python the Buffer object can be used to this end. Wherever pointer notation is used in the OpenGL functions the Buffer object can be used in it's BGL wrapper. In some instances the Buffer object will need to be initialized with the template parameter, while in other instances the user will want to create just a blank buffer which will be zeroed by default.

Example with Buffer:
 import Blender
 from Blender import BGL
 myByteBuffer = BGL.Buffer(BGL.GL_BYTE, [32,32])
 BGL.glGetPolygonStipple(myByteBuffer)
 print myByteBuffer.dimensions
 print myByteBuffer.list
 sliceBuffer = myByteBuffer[0:16]
 print sliceBuffer 

Method Summary
Buffer object __init__(type, dimensions, template)
This will create a new Buffer object for use with other BGL OpenGL commands.

Instance Variable Summary
  dimensions: The size of the Buffer.
  list: The contents of the Buffer.

Method Details

__init__(type, dimensions, template=None)
(Constructor)

This will create a new Buffer object for use with other BGL OpenGL commands. Only the type of argument to store in the buffer and the dimensions of the buffer are necessary. Buffers are zeroed by default unless a template is supplied, in which case the buffer is initialized to the template.
Parameters:
type - The format to store data in. The type should be one of GL_BYTE, GL_SHORT, GL_INT, or GL_FLOAT.
           (type=int)
dimensions - If the dimensions are specified as an int a linear array will be created for the buffer. If a sequence is passed for the dimensions, the buffer becomes n-Dimensional, where n is equal to the number of parameters passed in the sequence. Example: [256,2] is a two- dimensional buffer while [256,256,4] creates a three- dimensional buffer. You can think of each additional dimension as a sub-item of the dimension to the left. i.e. [10,2] is a 10 element array each with 2 sub-items. [(0,0), (0,1), (1,0), (1,1), (2,0), ...] etc.
           (type=An int or sequence object specifying the dimensions of the buffer.)
template - A sequence of matching dimensions which will be used to initialize the Buffer. If a template is not passed in all fields will be initialized to 0.
           (type=A python sequence object (optional))
Returns:
The newly created buffer as a PyObject.
           (type=Buffer object)

Instance Variable Details

dimensions

The size of the Buffer.

list

The contents of the Buffer.

Generated by Epydoc 2.1 on Thu May 10 20:31:59 2007 http://epydoc.sf.net