program.ProgramDescription
- moderngl_window.meta.program.ProgramDescription[source]
Describes a program to load
By default a program can be loaded in the following ways:
By supplying a path to s single glsl file containing all shaders
By supplying several paths to separate files containing each shader type. For example
vertex_shader,fragment_shader.. etc.
# Single glsl file containing all shaders ProgramDescription(path='programs/myprogram.glsl') # Multiple shader files ProgramDescription( vertex_shader='programs/myprogram_vs.glsl'. fragment_shader='programs/myprogram_fs.glsl'. geometry_shader='programs/myprogram_gs.glsl'. )
Methods
- ProgramDescription.__init__(path: str | None = None, kind: str | None = None, reloadable=False, vertex_shader: str | None = None, geometry_shader: str | None = None, fragment_shader: str | None = None, tess_control_shader: str | None = None, tess_evaluation_shader: str | None = None, compute_shader: str | None = None, defines: dict | None = None, varyings: List | None = None, **kwargs)[source]
Create a program description
- Keyword Arguments:
path (str) – path to the resource relative to search directories
kind (str) – The kind of loader to use
reloadable (bool) – Should this program be reloadable
vertex_shader (str) – Path to vertex shader file
geometry_shader (str) – Path to geometry shader
fragment_shader (str) – Path to fragmet shader
tess_control_shader (str) –
tess_evaluation_shader (str) – Path to tess eval shader
compute_shader (str) – Path to compute shader
defines (dict) – Dictionary with define values to replace in the source
varyings (List) – List of varying names for transform shader
**kwargs – Optional custom attributes
Attributes
- ProgramDescription.tess_evaluation_shader
Relative path to tessellation evaluation shader
- Type:
str
- ProgramDescription.vertex_shader
Relative path to vertex shader
- Type:
str
- ProgramDescription.geometry_shader
Relative path to geometry shader
- Type:
str
- ProgramDescription.reloadable
if this program is reloadable
- Type:
bool
- ProgramDescription.fragment_shader
Relative path to fragment shader
- Type:
str
- ProgramDescription.tess_control_shader
Relative path to tess control shader
- Type:
str
- ProgramDescription.compute_shader
Relative path to compute shader
- Type:
str
- ProgramDescription.defines
Dictionary with define values to replace in the source
- Type:
dict
- ProgramDescription.varyings
List of varying names for transform shaders
- Type:
List
Inherited Attributes
- ProgramDescription.path
The path to a resource when a single file is specified
- Type:
str
- ProgramDescription.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
- ProgramDescription.attrs
All keywords arguments passed to the resource
- Type:
dict
- ProgramDescription.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
- ProgramDescription.kind
default resource kind.
The resource
kindis directly matched with thekindin loader classes.This property also supports assignment and is useful if the
kindis detected based in the the attribute values.description.kind = 'something'
- Type:
str
- ProgramDescription.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
- ProgramDescription.default_kind = None
The default kind for this resource type
- Type:
str
- ProgramDescription.resource_type = 'programs'
A unique identifier for the resource type
- Type:
str