vispy.visuals.shaders.multiprogram module

class vispy.visuals.shaders.multiprogram.MultiProgram(vcode='', fcode='', gcode=None)[source]

Bases: object

A collection of ModularPrograms that emulates the API of a single ModularProgram.

A single Visual is often drawn in many different ways–viewed under different transforms, with different clipping boundaries, or with different colors as in picking and anaglyph stereo. Each draw may require a different program. To simplify this process, MultiProgram exposes an API that looks very much like a single ModularProgram, but internally manages many programs.


Create a program and add it to this MultiProgram.

It is the caller’s responsibility to keep a reference to the returned program.

The name must be unique, but is otherwise arbitrary and used for debugging purposes.

property frag

A wrapper around all fragment shaders contained in this MultiProgram.

property geom

A wrapper around all geometry shaders contained in this MultiProgram.

property vert

A wrapper around all vertex shaders contained in this MultiProgram.

class vispy.visuals.shaders.multiprogram.MultiShader(program, shader)[source]

Bases: object

Emulates the API of a MainFunction while wrapping all vertex or fragment shaders in a MultiProgram.


mp = MultiProgram(vert, frag)

# applies to all programs
mp.vert['u_scale'] = (1, 2)

# applies to one program
mp.get_program('p1').frag['u_color'] = (1, 1, 1, 1)