program.single.Loader

Method

Loader.__init__(meta)

Initialize loader.

Loaders take a ResourceDescription instance containing all the parameters needed to load and initialize this data.

Parameters:

meta (ResourceDescription) – The resource to load

classmethod Loader.supports_file(meta)

Check if the loader has a supported file extension.

What extensions are supported can be defined in the file_extensions class attribute.

Loader.load() → moderngl.program.Program[source]

Loads a shader program from a single glsl file.

Each shader type is separated by preprocessors

  • VERTEX_SHADER

  • FRAGMENT_SHADER

  • GEOMETRY_SHADER

  • TESS_CONTROL_SHADER

  • TESS_EVALUATION_SHADER

Example:

#version 330

#if defined VERTEX_SHADER

in vec3 in_position;
in vec2 in_texcoord_0;
out vec2 uv0;

void main() {
    gl_Position = vec4(in_position, 1);
    uv0 = in_texcoord_0;
}

#elif defined FRAGMENT_SHADER

out vec4 fragColor;
uniform sampler2D texture0;
in vec2 uv0;

void main() {
    fragColor = texture(texture0, uv0);
}
#endif
Returns:

The Program instance

Return type:

moderngl.Program

Loader.find_data(path)

Find resource using data finders.

This is mainly a shortcut method to simplify the task.

Parameters:

path – Path to resource

Loader.find_program(path)

Find resource using program finders.

This is mainly a shortcut method to simplify the task.

Parameters:

path – Path to resource

Loader.find_texture(path)

Find resource using texture finders.

This is mainly a shortcut method to simplify the task.

Parameters:

path – Path to resource

Loader.find_scene(path)

Find resource using scene finders.

This is mainly a shortcut method to simplify the task.

Parameters:

path – Path to resource

Attributes

Loader.kind = 'single'
Loader.file_extensions = []
Loader.ctx

ModernGL context

Type:

moderngl.Context