texture.TextureDescription¶
-
moderngl_window.meta.texture.
TextureDescription
[source]¶ Describes a texture to load.
Example:
# Loading a 2d texture TextureDescription(path='textures/wood.png') # Loading a 2d texture with mimpmaps with anisotropy TextureDescription(path='textures/wood.png', mipmap=True, anisotropy=16.0) # Loading texture array containing 10 layers TextureDescription(path='textures/tiles.png', layers=10, kind='array')
Methods¶
-
TextureDescription.
__init__
(path: str = None, kind: str = None, flip=True, flip_x=False, flip_y=True, mipmap=False, mipmap_levels: Tuple[int, int] = None, anisotropy=1.0, image=None, layers=None, pos_x: str = None, pos_y: str = None, pos_z: str = None, neg_x: str = None, neg_y: str = None, neg_z: str = None, **kwargs)[source]¶ Describes a texture resource
- Parameters
path (str) – path to resource relative to search directories
kind (str) – The kind of loader to use
flip (boolean) – (use flip_y) Flip the image vertically (top to bottom)
flip_x (boolean) – Flip the image horizontally (left to right)
flip_y (boolean) – Flip the image vertically (top to bottom)
mipmap (bool) – Generate mipmaps. Will generate max possible levels unless mipmap_levels is defined.
mipmap_levels (tuple) – (base, max_level) controlling mipmap generation. When defined the mipmap parameter is automatically True.
anisotropy (float) – Number of samples for anisotropic filtering
image – PIL image for when loading embedded resources
layers – (int): Number of layers for texture arrays
neg_x (str) – Path to negative x texture in a cube map
neg_y (str) – Path to negative y texture in a cube map
neg_z (str) – Path to negative z texture in a cube map
pos_x (str) – Path to positive x texture in a cube map
pop_y (str) – Path to positive y texture in a cube map
pos_z (str) – Path to positive z texture in a cube map
**kwargs – Any optional/custom attributes
Attributes¶
-
TextureDescription.
mipmap
¶ If mipmaps should be generated
- Type
bool
-
TextureDescription.
image
¶ PIL image when loading embedded resources
- Type
Image
-
TextureDescription.
layers
¶ Number of layers in texture array
- Type
int
-
TextureDescription.
anisotropy
¶ Number of samples for anisotropic filtering
- Type
float
-
TextureDescription.
mipmap_levels
¶ base, max_level for mipmap generation
- Type
Tuple[int, int]
-
TextureDescription.
flip_x
¶ If the image should be flipped horizontally (left to right)
- Type
bool
-
TextureDescription.
flip_y
¶ If the image should be flipped vertically (top to bottom)
- Type
bool
-
TextureDescription.
pos_x
¶ Path to positive x in a cubemap texture
- Type
str
-
TextureDescription.
pos_y
¶ Path to positive y in a cubemap texture
- Type
str
-
TextureDescription.
pos_z
¶ Path to positive z in a cubemap texture
- Type
str
-
TextureDescription.
neg_x
¶ Path to negative x in a cubemap texture
- Type
str
-
TextureDescription.
neg_y
¶ Path to negative y in a cubemap texture
- Type
str
-
TextureDescription.
neg_z
¶ Path to negative z in a cubemap texture
- Type
str
Inherited Attributes¶
-
TextureDescription.
path
¶ The path to a resource when a single file is specified
- Type
str
-
TextureDescription.
resolved_path
¶ The resolved path by a finder.
The absolute path to the resource can optionally be assigned by a loader class.
- Type
pathlib.Path
-
TextureDescription.
attrs
¶ All keywords arguments passed to the resource
- Type
dict
-
TextureDescription.
label
¶ optional name for the resource
Assigning a label is not mandatory but can help when aliasing resources. Some prefer to preload all needed resources and fetch them later by the label. This can he a lot less chaotic in larger applications.
- Type
str
-
TextureDescription.
kind
¶ default resource kind.
The resource
kind
is directly matched with thekind
in loader classes.This property also supports assignment and is useful if the
kind
is detected based in the the attribute values.description.kind = 'something'
- Type
str
-
TextureDescription.
loader_cls
¶ The loader class for this resource.
This property is assigned to during the loading stage were a loader class is assigned based on the kind.
- Type
Type
-
TextureDescription.
default_kind
= '2d'¶
-
TextureDescription.
resource_type
= 'textures'¶