OpenGL.arrays.numpymodule | index /var/pylive/src/OpenGL-dev/OpenGL-ctypes/OpenGL/arrays/numpymodule.py

`Numpy (new version) module implementation of the OpenGL-ctypes array interfaces
XXX Need to register handlers for all of the scalar types that numpy returns,
would like to have all return values be int/float if they are of compatible
type as well.`

Modules
`` |  |
OpenGL.constant OpenGL.constants | OpenGL.arrays.formathandler numpy | operator |

Classes
`` |  | FormatHandler(object) NumpyHandler
class NumpyHandler(FormatHandler)
`` | `Numpy-specific data-type handler for OpenGL Attributes: ERROR_ON_COPY -- if True, will raise errors if we have to copy an array object in order to produce a contiguous array of the correct type.`
| Method resolution order: NumpyHandler FormatHandler object Methods defined here: arrayByteCount(self, value, typeCode=None) `Given a data-value, calculate number of bytes required to represent` arraySize(self, value, typeCode=None) `Given a data-value, calculate dimensions for the array` arrayToGLType(self, value) `Given a value, guess OpenGL type of the corresponding pointer` asArray(self, value, typecode=None) `Convert given value to an array value of given typecode` contiguous(self, source, typecode=None) `Get contiguous array from source source -- numpy Python array (or compatible object) for use as the data source. If this is not a contiguous array of the given typecode, a copy will be made, otherwise will just be returned unchanged. typecode -- optional 1-character typecode specifier for the numpy.array function. All gl*Pointer calls should use contiguous arrays, as non- contiguous arrays will be re-copied on every rendering pass. Although this doesn't raise an error, it does tend to slow down rendering.` dataPointer(self, instance) `Convert given instance to a data-pointer value (integer)` dimensions(self, value, typeCode=None) `Determine dimensions of the passed array value (if possible)` from_param = dataPointer(self, instance) unitSize(self, value, typeCode=None) `Determine unit size of an array (if possible)` voidDataPointer(cls, value) `Given value in a known data-pointer type, return void_p for pointer` zeros(self, dims, typeCode) `Return Numpy array of zeros in given size` Data and other attributes defined here: ERROR_ON_COPY = False HANDLED_TYPES = (<type 'numpy.ndarray'>, <type 'list'>, <type 'tuple'>) Methods inherited from FormatHandler: register(self, types=None) `Register this class as handler for given set of types` registerEquivalent(self, typ, base) `Register a sub-class for handling as the base-type` registerReturn(self) `Register this handler as the default return-type handler` Class methods inherited from FormatHandler: chooseOutput(cls, preferred=None) from type `Choose our output-capable plugin` loadAll(cls) from type `Load all setuptools-registered FormatHandler classes register a new datatype with code similar to this in your package's setup.py for setuptools: entry_points = { 'OpenGL.arrays.formathandler':[ 'numpy = OpenGL.arrays.numpymodule.NumpyHandler', ], }` Data descriptors inherited from FormatHandler: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)` Data and other attributes inherited from FormatHandler: ALL_OUTPUT_HANDLERS = [] GENERIC_OUTPUT_PREFERENCES = ['numpy', 'ctypesarrays'] HANDLER_REGISTRY = {} TYPE_REGISTRY = {} baseType = None preferredOutput = None typeConstant = None

Functions
`` |  | dataPointer(self, instance) `Convert given instance to a data-pointer value (integer)`

Data
`` |  | ARRAY_TO_GL_TYPE_MAPPING = {'I': GL_UNSIGNED_INT, 'b': GL_BYTE, 'c': GL_UNSIGNED_BYTE, 'd': GL_DOUBLE, 'f': GL_FLOAT, 'i': GL_INT, 'short': GL_SHORT} GL_TYPE_TO_ARRAY_MAPPING = {GL_BYTE: 'b', GL_UNSIGNED_BYTE: 'b', GL_SHORT: 'short', GL_UNSIGNED_SHORT: 'short', GL_INT: 'i', GL_UNSIGNED_INT: 'i', GL_FLOAT: 'f', GL_DOUBLE: 'd'} REGISTRY_NAME = 'numpy' SHORT_TYPE = 'short' err = TypeError('data type not understood',) testArray = array([1, 2, 3, 4], dtype=int32)