OpenGLContext.texture
index
p:\openglcontext\texture.py

Resource-manager for textures (with PIL conversions)

 
Modules
            
Numeric
 
Classes
            
object
Texture
MMTexture
 
class MMTexture(Texture)
      Mip-mapped texture object
 
Note: You'll want your images to use
minFilter = GL_LINEAR_MIPMAP_NEAREST
to actually see any effect from using a
MMTexture.
 
  
Method resolution order:
MMTexture
Texture
object

Methods defined here:
ensurePow2(self, image)
Ensure that the PIL image is pow2 x pow2 dimensions
 
Mip-mapping does this already if I'm not mistaken, so
we just return image unchanged.
store(self, components, format, x, y, image)
define the texture's parameters...
components -- number of components (3 or 4 for
        RGB and RGBA respectively)
format -- GL_RGB, GL_RGBA, GL_LUMINANCE
x,y -- dimensions of the image
image -- string, data in raw (unencoded) format

Data and non-method functions defined here:
__doc__ = "Mip-mapped texture object\n\n\tNote: You'll want yo...ctually see any effect from using a\n\tMMTexture.\n\t"
__module__ = 'OpenGLContext.texture'

Methods inherited from Texture:
__call__(self)
Enable and select the texture...
See:
        glBindTextureglEnable(GL_TEXTURE_2D)
__del__(self, glDeleteTextures=<built-in function glDeleteTextures>)
Clean up the OpenGL display-list resources
See:
        glDeleteTextures
__init__(self, image=None)
Initialise the texture, if image is not None, store it
 
image -- optional PIL image to store
ensureRGB(self, image)
Ensure that the PIL image is in RGB mode
 
Note:
        This method will create a _new_ PIL image if
        the image is in Paletted mode, otherwise just
        returns the same image object.
fromPIL(self, image)
Automated storage of image data from a PIL Image instance
 
Uses the ensureRGB method to convert the image to RGB,
then ensurePow2 to make the image a valid size for OpenGL,
then calls store(...) with the appropriate arguments.
 
Returns the number of components in the image

Data and non-method functions inherited from Texture:
__dict__ = <dict-proxy object at 0x07156738>
__weakref__ = <member '__weakref__' of 'Texture' objects>

Methods inherited from object:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__hash__(...)
x.__hash__() <==> hash(x)
__reduce__(...)
helper for pickle
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__str__(...)
x.__str__() <==> str(x)

Data and non-method functions inherited from object:
__class__ = <type 'type'>
__new__ = <built-in method __new__ of type object at 0x1E0BD978>
T.__new__(S, ...) -> a new object with type S, a subtype of T
 
class Texture(object)
      Holder for an OpenGL compiled texture
 
This object holds onto a texture until it
is deleted.  Provides methods for storing
raw data or PIL images (store and fromPIL
respectively)
 
Attributes:
        components -- number of components in the image,
                if 0, then there is no currently stored image
        texture -- OpenGL textureID as returned by a call
                to glGenTextures(1), will be freed when the
                Texture object is deleted
 
   Methods defined here:
__call__(self)
Enable and select the texture...
See:
        glBindTextureglEnable(GL_TEXTURE_2D)
__del__(self, glDeleteTextures=<built-in function glDeleteTextures>)
Clean up the OpenGL display-list resources
See:
        glDeleteTextures
__init__(self, image=None)
Initialise the texture, if image is not None, store it
 
image -- optional PIL image to store
ensurePow2(self, image)
Ensure that the PIL image is pow2 x pow2 dimensions
 
Note:
        This method will create a _new_ PIL image if
        the image is not a valid size (It will use BICUBIC
        filtering (from PIL) to do the resizing). Otherwise
        just returns the same image object.
ensureRGB(self, image)
Ensure that the PIL image is in RGB mode
 
Note:
        This method will create a _new_ PIL image if
        the image is in Paletted mode, otherwise just
        returns the same image object.
fromPIL(self, image)
Automated storage of image data from a PIL Image instance
 
Uses the ensureRGB method to convert the image to RGB,
then ensurePow2 to make the image a valid size for OpenGL,
then calls store(...) with the appropriate arguments.
 
Returns the number of components in the image
store(self, components, format, x, y, image)
define the texture's parameters...
        components -- number of components (3 or 4 for
                RGB and RGBA respectively)
        format -- GL_RGB, GL_RGBA, GL_LUMINANCE
        x,y -- dimensions of the image
        image -- string, data in raw (unencoded) format
 
See:
        glBindTextureglPixelStoreiglTexImage2D

Data and non-method functions defined here:
__dict__ = <dict-proxy object at 0x0736C5E8>
__doc__ = 'Holder for an OpenGL compiled texture\n\n\tThis obj... be freed when the\n\t\t\tTexture object is deleted\n\t'
__module__ = 'OpenGLContext.texture'
__weakref__ = <member '__weakref__' of 'Texture' objects>

Methods inherited from object:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__hash__(...)
x.__hash__() <==> hash(x)
__reduce__(...)
helper for pickle
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__str__(...)
x.__str__() <==> str(x)

Data and non-method functions inherited from object:
__class__ = <type 'type'>
__new__ = <built-in method __new__ of type object at 0x1E0BD978>
T.__new__(S, ...) -> a new object with type S, a subtype of T
 
Functions
            
bestSize(dim)
Try to figure out the best power-of-2 size for the given dimension
 
At the moment, this is the next-largest power-of-two
which is also <= glGetInteger( GL_MAX_TEXTURE_SIZE ).
getLengthFormat(image)
Return PIL image component-length and format
 
This returns the number of components, and the OpenGL
mode constant describing the PIL image's format.  It
currently only supports GL_RGBA, GL_RGB and GL_LUIMANCE
formats (PIL: RGBA, RGBX, RGB, and L), the Texture
object's ensureRGB converts Paletted images to RGB
before they reach this function.
 
Data
             texture_log = <logging.Logger instance at 0x056EB9E0>