Texture3D Class

Inheritance diagram of Texture3D

class Texture3D(width, height, target, id)

A texture with more than one image slice.

Use create_for_images or create_for_image_grid classmethod to construct.

Constructor:

__init__(width, height, target, id)

Methods:

blit(x, y[, z, width, height])
blit_into(source, x, y, z)
blit_to_texture(target, level, x, y[, z]) Draw this image on the currently bound texture at target.
create(width, height[, internalformat, ...]) Create an empty Texture.
create_for_image_grid(grid[, internalformat])
create_for_images(images[, internalformat])
create_for_size(target, min_width, min_height) Create a Texture with dimensions at least min_width, min_height.
delete() Delete the texture from video memory.
get_animation(period[, loop]) Create an animation over this image sequence for the given constant framerate.
get_image_data([z]) Get the image data of this texture.
get_mipmapped_texture() Retrieve a Texture instance with all mipmap levels filled in.
get_region(x, y, width, height)
get_texture([rectangle, force_rectangle])
get_texture_sequence()
get_transform([flip_x, flip_y, rotate]) Create a copy of this image applying a simple transformation.
save([filename, file, encoder]) Save this image to a file.

Attributes:

anchor_x Type: int
anchor_y Type: int
image_data An ImageData view of this texture.
images Type: int
item_height Type: int
item_width Type: int
items Type: tuple
level Type: int
mipmapped_texture A Texture view of this image.
tex_coords Type: tuple
tex_coords_order Type: tuple
texture Get a Texture view of this image.
texture_sequence Access this image sequence as a texture sequence.
x Type: int
y Type: int
z Type: int

Methods

classmethod Texture3D.create_for_image_grid(grid, internalformat=6408)
classmethod Texture3D.create_for_images(images, internalformat=6408)

Attributes

Texture3D.item_height = 0
Texture3D.item_width = 0
Texture3D.items = ()

Inherited members

Methods

Texture3D.blit(x, y, z=0, width=None, height=None)
Texture3D.blit_into(source, x, y, z)
Texture3D.blit_to_texture(target, level, x, y, z=0)

Draw this image on the currently bound texture at target.

This image is copied into the texture such that this image’s anchor point is aligned with the given x and y coordinates of the destination texture. If the currently bound texture is a 3D texture, the z coordinate gives the image slice to blit into.

classmethod Texture3D.create(width, height, internalformat=6408, rectangle=False, force_rectangle=False, min_filter=9729, mag_filter=9729)

Create an empty Texture.

If rectangle is False or the appropriate driver extensions are not available, a larger texture than requested will be created, and a TextureRegion corresponding to the requested size will be returned.

Parameters:
  • width (int) – Width of the texture.
  • height (int) – Height of the texture.
  • internalformat (int) – GL constant giving the internal format of the texture; for example, GL_RGBA.
  • rectangle (bool) – True if a rectangular texture is permitted. See AbstractImage.get_texture.
  • force_rectangle (bool) – True if a rectangular texture is required. See AbstractImage.get_texture. Since: pyglet 1.1.4.
  • min_filter (int) – The minifaction filter used for this texture, commonly GL_LINEAR or GL_NEAREST
  • mag_filter (int) – The magnification filter used for this texture, commonly GL_LINEAR or GL_NEAREST
Return type:

Texture

Note

Since pyglet 1.1

classmethod Texture3D.create_for_size(target, min_width, min_height, internalformat=None, min_filter=9729, mag_filter=9729)

Create a Texture with dimensions at least min_width, min_height. On return, the texture will be bound.

Parameters:
  • target (int) – GL constant giving texture target to use, typically GL_TEXTURE_2D.
  • min_width (int) – Minimum width of texture (may be increased to create a power of 2).
  • min_height (int) – Minimum height of texture (may be increased to create a power of 2).
  • internalformat (int) – GL constant giving internal format of texture; for example, GL_RGBA. If unspecified, the texture will not be initialised (only the texture name will be created on the instance). If specified, the image will be initialised to this format with zero’d data.
  • min_filter (int) – The minifaction filter used for this texture, commonly GL_LINEAR or GL_NEAREST
  • mag_filter (int) – The magnification filter used for this texture, commonly GL_LINEAR or GL_NEAREST
Return type:

Texture

Texture3D.delete()

Delete the texture from video memory.

Warning

Deprecated. Textures are automatically released during object finalization.

Texture3D.get_animation(period, loop=True)

Create an animation over this image sequence for the given constant framerate.

:Parameters
period : float
Number of seconds to display each frame.
loop : bool
If True, the animation will loop continuously.
Return type:Animation

Note

Since pyglet 1.1

Texture3D.get_image_data(z=0)

Get the image data of this texture.

Changes to the returned instance will not be reflected in this texture.

Parameters:z (int) – For 3D textures, the image slice to retrieve.
Return type:ImageData
Texture3D.get_mipmapped_texture()

Retrieve a Texture instance with all mipmap levels filled in.

Requires that image dimensions be powers of 2.

Return type:Texture

Note

Since pyglet 1.1

Texture3D.get_region(x, y, width, height)
Texture3D.get_texture(rectangle=False, force_rectangle=False)
Texture3D.get_texture_sequence()
Texture3D.get_transform(flip_x=False, flip_y=False, rotate=0)

Create a copy of this image applying a simple transformation.

The transformation is applied to the texture coordinates only; get_image_data will return the untransformed data. The transformation is applied around the anchor point.

Parameters:
  • flip_x (bool) – If True, the returned image will be flipped horizontally.
  • flip_y (bool) – If True, the returned image will be flipped vertically.
  • rotate (int) – Degrees of clockwise rotation of the returned image. Only 90-degree increments are supported.
Return type:

TextureRegion

Texture3D.save(filename=None, file=None, encoder=None)

Save this image to a file.

Parameters:
  • filename (str) – Used to set the image file format, and to open the output file if file is unspecified.
  • file (file-like object or None) – File to write image data to.
  • encoder (ImageEncoder or None) – If unspecified, all encoders matching the filename extension are tried. If all fail, the exception from the first one attempted is raised.

Attributes

Texture3D.anchor_x = 0
Texture3D.anchor_y = 0
Texture3D.image_data

An ImageData view of this texture.

Changes to the returned instance will not be reflected in this texture. If the texture is a 3D texture, the first image will be returned. See also get_image_data. Read-only.

Warning

Deprecated. Use get_image_data.

Type:ImageData
Texture3D.images = 1
Texture3D.level = 0
Texture3D.mipmapped_texture

A Texture view of this image.

The returned Texture will have mipmaps filled in for all levels. Requires that image dimensions be powers of 2. Read-only.

Warning

Deprecated. Use get_mipmapped_texture.

Type:Texture
Texture3D.tex_coords = (0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0)
Texture3D.tex_coords_order = (0, 1, 2, 3)
Texture3D.texture

Get a Texture view of this image.

Changes to the returned instance may or may not be reflected in this image.

Warning

Deprecated. Use get_texture.

Type:Texture
Texture3D.texture_sequence

Access this image sequence as a texture sequence.

Warning

Deprecated. Use get_texture_sequence

Type:TextureSequence
Texture3D.x = 0
Texture3D.y = 0
Texture3D.z = 0

Table Of Contents

Previous topic

Texture Class

Next topic

TextureGrid Class