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, mipmap=False, mipmap_levels: Tuple[int, int] = None, anisotropy=1.0, image=None, layers=None, **kwargs)[source]¶ Describes a texture resource
- Parameters
path (str) – path to resource relative to search directories
flip (boolean) – Flip the image horisontally
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
kind (str) – The kind of loader to use
image – PIL image for when loading embedded resources
layers – (int): Number of layers for texture arrays
**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
¶ If the image should be flipped horisontally
- Type
bool
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 loder 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'¶