77. opengl.shader — OpenGL shader programs — pyFormex 1.0.5 documentation

# 77. `opengl.shader` — OpenGL shader programs

Python OpenGL framework for pyFormex

This module is responsible for loading the shader programs and its data onto the graphics system.

3. 2013 Benedict Verhegghe and the pyFormex project.

class `opengl.shader.` `Shader`(vshader=None, fshader=None, attributes=None, uniforms=None)

  An OpenGL shader consisting of a vertex and a fragment shader pair.

  Class attributes:

  - _vertexshader : the vertex shader source. By default, a basic shader supporting vertex positions and vertex colors is defined
  - _fragmentshader : the fragment shader source. By default, a basic shader supporting fragment colors is defined.
  - attributes: the shaders’ vertex attributes.
  - uniforms: the shaders’ uniforms.
  `locations`(func, keys)

    Create a dict with the locations of the specified keys

  `uniformInt`(name, value)

    Load a uniform integer or boolean into the shader

  `uniformFloat`(name, value)

    Load a uniform float into the shader

  `uniformVec3`(name, value)

    Load a uniform vec3[n] into the shader

    The value should be a 1D array or list.

  `uniformMat4`(name, value)

    Load a uniform mat4 into the shader

  `uniformMat3`(name, value)

    Load a uniform mat3 into the shader

  `bind`(picking=False)

    Bind the shader program

  `unbind`()

    Unbind the shader program

  `loadUniforms`(D)

    Load the uniform attributes defined in D

    D is a dict with uniform attributes to be loaded into the shader program. The attributes can be of type int, float, or vec3.

## 77.1. Functions defined in module opengl.shader

`opengl.shader.` `defaultShaders`()

  Determine the default shader programs