Texture
(width, height, target, id)¶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:
__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_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
anchor_y
image_data
An ImageData view of this texture. images
level
mipmapped_texture
A Texture view of this image. tex_coords
tex_coords_order
texture
Get a Texture view of this image. x
y
z
Texture.
blit
(x, y, z=0, width=None, height=None)¶Texture.
blit_into
(source, x, y, z)¶Texture.
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: |
|
---|---|
Return type: | Texture |
Note
Since pyglet 1.1
Texture.
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: |
|
---|---|
Return type: | Texture |
Texture.
delete
()¶Delete the texture from video memory.
Warning
Deprecated. Textures are automatically released during object finalization.
Texture.
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 |
Texture.
get_region
(x, y, width, height)¶Texture.
get_texture
(rectangle=False, force_rectangle=False)¶Texture.
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: |
|
---|---|
Return type: | TextureRegion |
Texture.
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 |
---|
Texture.
images
= 1¶Texture.
level
= 0¶Texture.
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)¶Texture.
tex_coords_order
= (0, 1, 2, 3)¶Texture.
x
= 0¶Texture.
y
= 0¶Texture.
z
= 0¶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