OpenGL.images | index /home/mcfletch/pylive/OpenGL/images.py |
Image/texture implementation code
This module provides the Pan-OpenGL operations required to support OpenGL
image handling. Most of this code is simply boilerplate code that sets
OpenGL parameters such that normal Pythonic assumptions about data-ordering
are met to allow easier interaction with other projects (such as PIL or
Numpy).
Generally speaking, there are 3 pieces of information which control how
an image is processed in the system:
format -- this is the pixel format, such as GL_RGB/GL_RED/GL_ABGR_EXT
dims -- tuple of dimensions for the image, (width,height,depth) order
type -- the storage data-type for the image, normally GL_UNSIGNED_BYTE
when working in Python, but all of the standard OpenGL types for
images can be used if you happen to have your data in some exotic
format.
OpenGL.UNSIGNED_BYTE_IMAGES_AS_STRING -- if this global value is set,
then read of unsigned byte images using glReadPixels and
glGetTexImage produces a string instead of the default array format.
Attributes of Note:
COMPONENT_COUNTS -- used to lookup how many units of a
given storage type are required to store a unit in a given format
TYPE_TO_ARRAYTYPE -- maps Image storage types to their array data-type
constants, i.e. maps GL_UNSIGNED_SHORT_4_4_4_4 to GL_UNSIGNED_SHORT
so that we can use the standard array types for manipulating
image arrays.
RANK_PACKINGS -- commands required to set up default array-transfer
operations for an array of the specified rank.
New image formats and types will need to be registered here to be supported,
this means that extension modules which add image types/formats need to alter
the tables described above!
XXX Should be an API to handle that instead of direct modification.
Modules | ||||||
|
Functions | ||
|
Data | ||
COMPONENT_COUNTS = {GL_COLOR_INDEX: 1, GL_STENCIL_INDEX: 1, GL_DEPTH_COMPONENT: 1, GL_RED: 1, GL_GREEN: 1, GL_BLUE: 1, GL_ALPHA: 1, GL_RGB: 3, GL_RGBA: 4, GL_LUMINANCE: 1, ...} RANK_PACKINGS = {1: [(<CFunctionType object at 0x2580bb0>, GL_PACK_SKIP_PIXELS, 0), (<CFunctionType object at 0x2580bb0>, GL_PACK_ALIGNMENT, 1)], 2: [(<CFunctionType object at 0x2580bb0>, GL_PACK_ROW_LENGTH, 0), (<CFunctionType object at 0x2580bb0>, GL_PACK_SKIP_ROWS, 0), (<CFunctionType object at 0x2580bb0>, GL_PACK_ALIGNMENT, 1)], 3: [(<CFunctionType object at 0x2580bb0>, GL_PACK_SKIP_IMAGES, 0), (<CFunctionType object at 0x2580bb0>, GL_PACK_IMAGE_HEIGHT, 0), (<CFunctionType object at 0x2580bb0>, GL_PACK_ALIGNMENT, 1)], 4: [(<CFunctionType object at 0x2580bb0>, GL_PACK_SKIP_VOLUMES_SGIS, 0), (<CFunctionType object at 0x2580bb0>, GL_PACK_IMAGE_DEPTH_SGIS, 0), (<CFunctionType object at 0x2580bb0>, GL_PACK_ALIGNMENT, 1)]} TIGHT_PACK_FORMATS = {GL_BITMAP: 8, GL_UNSIGNED_BYTE_3_3_2: 3, GL_UNSIGNED_SHORT_4_4_4_4: 4, GL_UNSIGNED_SHORT_5_5_5_1: 4, GL_UNSIGNED_INT_8_8_8_8: 4, GL_UNSIGNED_INT_10_10_10_2: 4, GL_UNSIGNED_BYTE_2_3_3_REV: 3, GL_UNSIGNED_SHORT_5_6_5: 3, GL_UNSIGNED_SHORT_5_6_5_REV: 3, GL_UNSIGNED_SHORT_4_4_4_4_REV: 4, ...} TYPE_TO_ARRAYTYPE = {GL_BYTE: GL_BYTE, GL_UNSIGNED_BYTE: GL_UNSIGNED_BYTE, GL_SHORT: GL_SHORT, GL_UNSIGNED_SHORT: GL_UNSIGNED_SHORT, GL_INT: GL_INT, GL_UNSIGNED_INT: GL_UNSIGNED_INT, GL_FLOAT: GL_FLOAT, GL_DOUBLE: GL_DOUBLE, GL_BITMAP: GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE_3_3_2: GL_UNSIGNED_BYTE, ...} TYPE_TO_BITS = {} __file__ = '/home/mcfletch/pylive/OpenGL/images.pyc' __name__ = 'OpenGL.images' __package__ = 'OpenGL' |