Package VisionEgg :: Module Textures :: Class TextureObject
[frames] | no frames]

Class TextureObject

source code

object --+
         |
        TextureObject

Texture data in OpenGL. Potentially resident in video texture memory.

This class encapsulates the state variables in OpenGL texture objects.  Do not
change attribute values directly.  Use the methods provided instead.



Instance Methods
 
__init__(self, dimensions=2)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__del__(self) source code
 
is_resident(self) source code
 
set_priority(self, priority) source code
 
set_min_filter(self, filter) source code
 
set_mag_filter(self, filter) source code
 
set_wrap_mode_s(self, wrap_mode)
Set to GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT, or GL_CLAMP_TO_BORDER
source code
 
set_wrap_mode_t(self, wrap_mode)
Set to GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT, or GL_CLAMP_TO_BORDER
source code
 
set_wrap_mode_r(self, wrap_mode)
Set to GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT, or GL_CLAMP_TO_BORDER
source code
 
set_border_color(self, border_color)
Set to a sequence of 4 floats in the range 0.0 to 1.0
source code
 
put_new_image(self, texel_data, mipmap_level=0, border=0, check_opengl_errors=True, internal_format=gl.GL_RGB, data_format=None, data_type=None, cube_side=None)
Put numpy array or PIL Image into OpenGL as texture data.
source code
 
put_new_image_build_mipmaps(self, texel_data, internal_format=gl.GL_RGB, data_format=None, data_type=None, cube_side=None)
Similar to put_new_image(), but builds mipmaps.
source code
 
put_sub_image(self, texel_data, mipmap_level=0, offset_tuple=None, data_format=None, data_type=None, cube_side=None)
Replace all or part of a texture object.
source code
 
put_new_framebuffer(self, buffer='back', mipmap_level=0, border=0, framebuffer_lowerleft=None, size=None, internal_format=gl.GL_RGB, cube_side=None)
Replace texture object with the framebuffer contents.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, dimensions=2)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

put_new_image(self, texel_data, mipmap_level=0, border=0, check_opengl_errors=True, internal_format=gl.GL_RGB, data_format=None, data_type=None, cube_side=None)

source code 
Put numpy array or PIL Image into OpenGL as texture data.

The texel_data parameter contains the texture data.  If it is
a numpy array, it must be 1D, 2D, or 3D data in grayscale or
color (RGB or RGBA).  Remember that OpenGL begins its textures
from the lower left corner, so texel_data[0,:] = 1.0 would set
the bottom line of the texture to white, while texel_data[:,0]
= 1.0 would set the left line of the texture to white.

The mipmap_level parameter specifies which of the texture
object's mipmap arrays you are filling.

The border parameter specifies the width of the border.

The check_opengl_errors parameter turns on (more
comprehensible) error messages when something goes wrong.  It
also slows down performance a little bit.

The internal_format parameter specifies the format in which
the image data is stored on the video card.  See the OpenGL
specification for all possible values.

If the data_format parameter is None (the default), an attempt
is made to guess data_format according to the following
description. For numpy arrays: If texel_data.shape is equal
to the dimensions of the texture object, texel_data is assumed
to contain luminance (grayscale) information and data_format
is set to GL_LUMINANCE.  If texel_data.shape is equal to one
plus the dimensions of the texture object, texel_data is
assumed to contain color information.  If texel_data.shape[-1]
is 3, this is assumed to be RGB data and data_format is set to
GL_RGB.  If, texel_data.shape[-1] is 4, this is assumed to be
RGBA data and data_format is set to GL_RGBA. For PIL images:
the "mode" attribute is queried.

If the data_type parameter is None (the default), it is set to
GL_UNSIGNED_BYTE. For numpy arrays: texel_data is (re)cast
to UInt8 and, if it is a floating point type, values are
assumed to be in the range 0.0-1.0 and are scaled to the range
0-255.  If the data_type parameter is not None, the texel_data
is not rescaled or recast.  Currently only GL_UNSIGNED_BYTE is
supported. For PIL images: texel_data is used as unsigned
bytes.  This is the usual format for common computer graphics
files.

put_sub_image(self, texel_data, mipmap_level=0, offset_tuple=None, data_format=None, data_type=None, cube_side=None)

source code 
Replace all or part of a texture object.

This is faster that put_new_image(), and can be used to
rapidly update textures.

The offset_tuple parameter determines the lower left corner
(for 2D textures) of your data in pixel units.  For example,
(0,0) would be no offset and thus the new data would be placed
in the lower left of the texture.

For an explanation of most parameters, see the
put_new_image() method.

put_new_framebuffer(self, buffer='back', mipmap_level=0, border=0, framebuffer_lowerleft=None, size=None, internal_format=gl.GL_RGB, cube_side=None)

source code 
Replace texture object with the framebuffer contents.

The framebuffer_lowerleft parameter determines the lower left
corner of the framebuffer region from which to copy texel data
in pixel units.  For example, (0,0) would be no offset and
thus the new data would be placed from the lower left of the
framebuffer.

For an explanation of most parameters, see the
put_new_image() method.