Program#
Program#
- class arcade.gl.Program(ctx: Context, *, vertex_shader: str, fragment_shader: str = None, geometry_shader: str = None, tess_control_shader: str = None, tess_evaluation_shader: str = None, varyings: List[str] = None, varyings_capture_mode: str = 'interleaved')[source]#
Bases:
object
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 (Context) – The context this program belongs to
vertex_shader (str) – vertex shader source
fragment_shader (str) – fragment shader source
geometry_shader (str) – geometry shader source
tess_control_shader (str) – tessellation control shader source
tess_evaluation_shader (str) – tessellation evaluation shader source
varyings (List[str]) – List of out attributes used in transform feedback.
varyings_capture_mode (str) – 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.
- property attributes: Iterable[arcade.gl.types.AttribFormat]#
List of attribute information
- property out_attributes: List[str]#
Out attributes names used in transform feedback.
Warning
Old alias for
varyings
. May be removed in the future.- Type
list of str
- property varyings_capture_mode: str#
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.
- property geometry_input: int#
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
- property geometry_output: int#
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
- property geometry_vertices: int#
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.
- set_uniform_safe(name: str, value: Any)[source]#
Safely set a uniform catching KeyError.
- Parameters
name (str) – The uniform name
value (Any) – 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 (str) – Name of uniform
value (List[Any]) – List of values
- static compile_shader(source: str, shader_type: ctypes.c_uint) ctypes.c_uint [source]#
Compile the shader code of the given type.
shader_type could be GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, …
Returns the shader id as a GLuint