An image loaded into video memory that can be efficiently drawn to the framebuffer.
Typically you will get an instance of Texture by accessing the texture member of any other AbstractImage.
Variables: |
|
---|
Constructor:
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_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_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_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 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. x Type: int y Type: int z Type: int
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: |
|
---|---|
Return type: | Texture |
Note
Since pyglet 1.1
Create a Texture with dimensions at least min_width, min_height. On return, the texture will be bound.
Parameters: |
|
---|---|
Return type: | Texture |
Delete the texture from video memory.
Warning
Deprecated. Textures are automatically released during object finalization.
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 |
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: |
|
---|---|
Return type: | TextureRegion |
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 |
---|
Methods
- Texture.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.
- Texture.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
- Texture.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
- Texture.anchor_x = 0
- Texture.anchor_y = 0
- Texture.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
- Texture.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