Program#
Program#
- class arcade.gl.Program(ctx: Context, *, vertex_shader: str, fragment_shader: str | None = None, geometry_shader: str | None = None, tess_control_shader: str | None = None, tess_evaluation_shader: str | None = None, varyings: List[str] | None = None, varyings_capture_mode: str = 'interleaved')[source]#
Bases:
Compiled and linked shader program.
Currently supports vertex, fragment and geometry shaders. Transform feedback also supported when output attributes names are passed in the varyings parameter.
The best way to create a program instance is through
arcade.gl.Context.program()
Access Uniforms via the
[]
operator. Example:program['MyUniform'] = value
- Parameters:
ctx – The context this program belongs to
vertex_shader – vertex shader source
fragment_shader – fragment shader source
geometry_shader – geometry shader source
tess_control_shader – tessellation control shader source
tess_evaluation_shader – tessellation evaluation shader source
varyings – List of out attributes used in transform feedback.
varyings_capture_mode – The capture mode for transforms.
"interleaved"
means all out attribute will be written to a single buffer."separate"
means each out attribute will be written separate buffers. Based on these settings the transform() method will accept a single buffer or a list of buffer.
- ctx#
The context this program belongs to
- Type:
- attributes#
List of attribute information
- out_attributes#
Out attributes names used in transform feedback.
Warning
Old alias for
varyings
. May be removed in the future.
- varyings_capture_mode#
Get the capture more for transform feedback (single, multiple).
This is a read only property since capture mode can only be set before the program is linked.
- geometry_input#
The geometry shader’s input primitive type. This an be compared with
GL_TRIANGLES
,GL_POINTS
etc. and is queried when the program is created.- Type:
- geometry_output#
The geometry shader’s output primitive type. This an be compared with
GL_TRIANGLES
,GL_POINTS
etc. and is queried when the program is created.- Type:
- geometry_vertices#
The maximum number of vertices that can be emitted. This is queried when the program is created.
- Type:
- delete()[source]#
Destroy the underlying OpenGL resource. Don’t use this unless you know exactly what you are doing.
- static delete_glo(ctx, prog_id)[source]#
Deletes a program. This is normally called automatically when the program is garbage collected.
- Parameters:
ctx – The context
prog_id – The OpenGL resource id
- 🧙 self[item] Uniform | UniformBlock [source]#
Get a uniform or uniform block
- set_uniform_safe(name: str, value: Any)[source]#
Safely set a uniform catching KeyError.
- Parameters:
name – The uniform name
value – The uniform value
- set_uniform_array_safe(name: str, value: List[Any])[source]#
Safely set a uniform array. Arrays can be shortened by the glsl compiler not all elements are determined to be in use. This function checks the length of the actual array and sets a subset of the values if needed. If the uniform don’t exist no action will be done.
- Parameters:
name – Name of uniform
value – List of values
Program Members#
Uniform#
- class arcade.gl.uniform.Uniform(ctx, program_id, location, name, data_type, array_length)[source]#
Bases:
A Program uniform
- Parameters:
ctx – The context
program_id – The program id to which this uniform belongs
location – The uniform location
name – The uniform name
data_type – The data type of the uniform
array_length – The array length of the uniform
- location#
The location of the uniform in the program
- name#
Name of the uniform
- array_length#
Length of the uniform array. If not an array 1 will be returned
- components#
How many components for the uniform. A vec4 will for example have 4 components.
- getter#
- setter#
UniformBlock#
- class arcade.gl.uniform.UniformBlock(glo: int, index: int, size: int, name: str)[source]#
Bases:
Wrapper for a uniform block in shaders.
- glo#
The OpenGL object handle
- index#
The index of the uniform block
- size#
The size of the uniform block
- name#
The name of the uniform block
- binding#
Get or set the binding index for this uniform block