vispy.visuals.shaders.variable module#

class vispy.visuals.shaders.variable.InVar(var, array=False)#

Bases: Variable

definition(names, version, shader)#

Return the GLSL definition for this object. Use obj_names to determine the names of dependencies, and version (number, qualifier) to adjust code output.

property dtype#

The type of data (float, int, vec, mat, …).

expression(names)#

Return the GLSL expression used to reference this object inline.

property value#

The value associated with this variable.

class vispy.visuals.shaders.variable.Variable(name, value=None, vtype=None, dtype=None)#

Bases: ShaderObject

Representation of global shader variable

Parameters:
namestr

the name of the variable. This string can also contain the full definition of the variable, e.g. ‘uniform vec2 foo’.

value{float, int, tuple, GLObject}

If given, vtype and dtype are determined automatically. If a float/int/tuple is given, the variable is a uniform. If a gloo object is given that has a glsl_type property, the variable is an attribute and

vtype{‘const’, ‘uniform’, ‘attribute’, ‘varying’, ‘inout’}

The type of variable.

dtypestr

The data type of the variable, e.g. ‘float’, ‘vec4’, ‘mat’, etc.

definition(names, version, shader)#

Return the GLSL definition for this object. Use obj_names to determine the names of dependencies, and version (number, qualifier) to adjust code output.

property dtype#

The type of data (float, int, vec, mat, …).

expression(names)#

Return the GLSL expression used to reference this object inline.

property name#

The name of this variable.

property state_id#

Return a unique ID that changes whenever the state of the Variable has changed. This allows ModularProgram to quickly determine whether the value has changed since it was last used.

property value#

The value associated with this variable.

property vtype#

The type of variable (const, uniform, attribute, or varying).

For in/out variables (GLSL 150+), vtype is ‘varying’.

class vispy.visuals.shaders.variable.Varying(name, dtype=None)#

Bases: Variable

Representation of a varying (variables passed from one shader to the next).

Varyings can inherit their dtype from another Variable, allowing for more flexibility in composing shaders.

property dtype#

The type of data (float, int, vec, mat, …).

invar(array=False)#

Return a varying that defines itself using the same name as this, but as an in variable instead of out.

Link this Varying to another object from which it will derive its dtype.

This method is used internally when assigning an attribute to a varying using syntax function[varying] = attr.

property value#

The value associated with this variable.