moderngl_window.resources

class moderngl_window.resources.base.BaseRegistry[source]

Base class for all resource pools

add(meta: ResourceDescription) None[source]

Adds a resource description without loading it. The resource is loaded and returned when load_pool() is called.

Parameters:

meta (ResourceDescription) – The resource description

property count: int

The number of resource descriptions added. This is only relevant when using add and load_pool.

Type:

int

load(meta: ResourceDescription) Any[source]

Loads a resource using the configured finders and loaders.

Parameters:

meta (ResourceDescription) – The resource description

load_pool() Generator[tuple[ResourceDescription, Any], None, None][source]

Loads all the data files using the configured finders.

This is only relevant when resource have been added to this pool using add().

Returns:

Generator of (meta, resource) tuples

property loaders: Generator[type[BaseLoader], None, None]

Loader classes for this resource type

Type:

Generator

resolve_loader(meta: ResourceDescription) None[source]

Attempts to assign a loader class to a ResourceDescription.

Parameters:
settings_attr = ''

The name of the attribute in Settings containting a list of loader classes.

Type:

str

class moderngl_window.resources.data.DataFiles[source]

Bases: BaseRegistry

Registry for requested data files

load(meta: ResourceDescription) Any[source]

Load data file with the configured loaders.

Parameters:

meta (DataDescription) – the resource description

Returns:

The loaded resource

Return type:

Any

settings_attr = 'DATA_LOADERS'

The name of the attribute in Settings containting a list of loader classes.

Type:

str

class moderngl_window.resources.programs.Programs[source]

Bases: BaseRegistry

Handle program loading

load(meta: ResourceDescription) Program[source]

Loads a shader program with the configured loaders

Parameters:
Returns:

The shader program

Return type:

moderngl.Program

resolve_loader(meta: ResourceDescription) None[source]

Resolve program loader.

Determines if the references resource is a single or multiple glsl files unless kind is specified.

Parameters:

meta (ProgramDescription) – The resource description

settings_attr = 'PROGRAM_LOADERS'

The name of the attribute in Settings containting a list of loader classes.

Type:

str

class moderngl_window.resources.scenes.Scenes[source]

Bases: BaseRegistry

Handles scene loading

load(meta: ResourceDescription) Scene[source]

Load a scene with the configured loaders.

Parameters:
Returns:

The loaded scene

Return type:

Scene

settings_attr = 'SCENE_LOADERS'

The name of the attribute in Settings containting a list of loader classes.

Type:

str

class moderngl_window.resources.textures.Textures[source]

Bases: BaseRegistry

Handles texture resources

load(meta: ResourceDescription) Texture | TextureArray | TextureCube | Texture3D[source]

Loads a texture with the configured loaders.

Parameters:
Returns:

2d texture

Return type:

moderngl.Texture

Returns:

texture array if layers is supplied

Return type:

moderngl.TextureArray

settings_attr = 'TEXTURE_LOADERS'

The name of the attribute in Settings containting a list of loader classes.

Type:

str