shaders

Types

ShaderError = object of Defect
Unrecoverable errors in a shader
ShaderId = distinct GLuint
Identifies an individual shader
ShaderProgramId = distinct GLuint
Identifies a program of shaders
ShaderProgram[U; V; T] = object
  shaders: seq[ShaderId]
  programId: ShaderProgramId
A shader program and the associated shader IDs

Procs

proc create(shaderType: OglShaderType; src: string): ShaderId {...}{.
    raises: [GLerror, ShaderError], tags: [].}
Compiles and creates an OpenGL shader
proc destroy(shaderId: ShaderId) {...}{.raises: [GLerror], tags: [].}
Destroys ashader
proc linkProgram[U; V; T: static[int]](shaderIds: openArray[ShaderId]): ShaderProgram[
    U, V, T]
Creates a shader program
proc compileProgram[U; V; T: static[int]](shaders: array[OglShaderType, seq[string]]): ShaderProgram[
    U, V, T]
Creates a program out of a suite of shader sources
proc createProgram[U; V; T: static[int]](vertexShader, fragmentShader: string): ShaderProgram[
    U, V, T]
proc use[U; V; T: static[int]](program: ShaderProgram[U, V, T]; uniforms: U)
Uses a specific program
proc draw[U; V; T: static[int]](program: ShaderProgram[U, V, T]; uniforms: U; models: openArray[
    tuple[vao: VertexArray[V], textures: array[T, TextureId]]])
Uses a specific program
proc draw[U; V](program: ShaderProgram[U, V, 1]; uniforms: U;
              models: openArray[tuple[vao: VertexArray[V], texture: TextureId]])
Uses a specific program
proc draw[U; V](program: ShaderProgram[U, V, 0]; uniforms: U;
              vaos: openArray[VertexArray[V]])
Uses a specific program

Templates

template destroy(program: ShaderProgram)
Uses a specific program