ShaderProgram

Methods

ShaderProgram.uniform(name, value=None)

Set or get a uniform. If no value is specificed, the unform will be returned

Optionally uniforms and other objects can be fetched with shader[key].

Parameters:
  • name – Name of the uniform
  • value – Value for the uniform
Returns:

(optional) Uniform objects

ShaderProgram.prepare(reload=False)

Compiles all the shaders and links the program. If the linking is successful it builds the uniform and attribute map.

Parameters:reload – (boolean) Are we reloading this shader?

Source Methods

ShaderProgram.set_source(source:str)

Set a single source file. This is used when you have all shaders in one file separated by preprocessors.

Parameters:source – (string) The shader source
ShaderProgram.set_vertex_source(source:str)

Set the vertex shader source

Parameters:source – (string) Vertex shader source
ShaderProgram.set_geometry_source(source:str)

Set the geometry shader source

Parameters:source – (string) Geometry shader source
ShaderProgram.set_fragment_source(source:str)

Set the fragment shader source

Parameters:source – (string) Fragment shader source
ShaderProgram.release()

Frees the memory and invalidates the name associated with the program

Attributes

ShaderProgram.subroutines

tuple: The subroutine uniforms.

ShaderProgram.geometry_input

int: The geometry input primitive. The GeometryShader’s input primitive if the GeometryShader exists. The geometry input primitive will be used for validation.

ShaderProgram.geometry_output

int: The geometry output primitive. The GeometryShader’s output primitive if the GeometryShader exists.

ShaderProgram.geometry_vertices

int: The maximum number of vertices that the geometry shader will output.

ShaderProgram.mglo

The ModernGL Program object

ShaderProgram.glo

int: The internal OpenGL object. This values is provided for debug purposes only.

ShaderProgram.ctx

The moderngl context