Options
All
  • Public
  • Public/Protected
  • All
Menu

ShaderProgram is an abstraction for Shaders Programs that provides, blended output, easier variable bindings and other nice features.

Type parameters

  • ValueType

Hierarchy

Index

Constructors

constructor

Properties

Private bindings

bindings: IBindings

Private blendMode

blendMode: BlendMode

Private blendValue

blendValue: number

Private copyOnSwap

copyOnSwap: boolean

Private drawHook

drawHook: function

Type declaration

    • (values: ValueType, gl: WebGLRenderingContext, shader: ShaderProgram): any
    • Parameters

      • values: ValueType
      • gl: WebGLRenderingContext
      • shader: ShaderProgram

      Returns any

Private dynamicBlend

dynamicBlend: boolean

Private enabledAttribs

enabledAttribs: number[]

Private fragment

fragment: WebGLShader

Private fragmentSrc

fragmentSrc: string

Private locations

locations: object

Type declaration

  • [key: string]: number | WebGLUniformLocation

Private program

program: WebGLProgram

Private rctx

Private swapFrame

swapFrame: boolean

Private textureVars

textureVars: string[]

Private vertex

vertex: WebGLShader

Private vertexSrc

vertexSrc: string

Methods

Private _compile

  • _compile(): void

Private _compileShader

  • _compileShader(shaderSrc: string, type: number): WebGLShader

Private _isShaderBlend

  • _isShaderBlend(mode: any): boolean

Private _setGlBlendMode

  • _setGlBlendMode(mode: any, blendValue: any): void

destroy

  • destroy(): void

disableAttrib

  • disableAttrib(name: string): void

Private draw

  • draw(values: ValueType): void

getLocation

  • getLocation(name: string, attrib?: boolean): number | WebGLUniformLocation
  • Returns the location of a uniform or attribute.

    Locations are cached

    Parameters

    • name: string

      name of the variable

    • Default value attrib: boolean = false

      if true then name is assumed to be an attribute

    Returns number | WebGLUniformLocation

getTextureId

  • getTextureId(name: string): number
  • Returns the index of a texture. Assigns id if not already assigned.

    Parameters

    • name: string

      name of the texture

    Returns number

run

  • Runs the shader program

    Parameters

    • tsm: TextureSetManager

      the texture set in which the rendering will be made

    • values: ValueType

      an object containing values for variables specified in the bindings

    • Default value blendMode: BlendMode = null

      the blendMode for this render

    • Default value blendValue: number = null

      blendValue when blendMode is ADJUSTABLE

    Returns void

setAttrib

  • setAttrib(name: string, buffer: Buffer, size?: number, type?: number, normalized?: boolean, stride?: number, offset?: number): void
  • Binds an attribute buffer and sets up vertex pointer

    Parameters

    • name: string

      name of the attribute

    • buffer: Buffer

      buffer to be bound

    • Default value size: number = 2

      size of values

    • Default value type: number = this.rctx.getGl().FLOAT

      type of values

    • Default value normalized: boolean = false

      enables normalization for integers

    • Default value stride: number = 0

      array value stride

    • Default value offset: number = 0

      offset of first value

    Returns void

setIndex

  • setIndex(buffer: Buffer): void

setUniform

  • setUniform(name: string, type: WebGLVarType, ...values: any[]): void
  • Binds value of a uniform variable in this program.

    Parameters

    • name: string

      name of the uniforma variable

    • type: WebGLVarType

      type of the value

    • Rest ...values: any[]

      value(s) to be bound

    Returns void

Object literals

Static Private shaderBlendEq

shaderBlendEq: object

__computed

__computed: string = "clamp(color * texture2D(u_srcTexture, v_position) * 256.0, 0.0, 1.0)"