GLShader |

a base GL Shader object

Index

Constructors

constructor

  • Parameters

    • gl: WebGLRenderingContext

      the current WebGL rendering context

    • vertex: string

      a string containing the GLSL source code to set

    • fragment: string

      a string containing the GLSL source code to set

    • Optionalprecision: string

      float precision ('lowp', 'mediump' or 'highp').

    Returns GLShader

Properties

attributes

attributes: number[]

the location attributes of the shader

fragment

fragment: string

the fragment shader source code

gl

the active gl rendering context

program

a reference to the shader program (once compiled)

uniforms

uniforms: object

the uniforms of the shader

vertex

vertex: string

the vertex shader source code

Methods

bind

  • Installs this shader program as part of current rendering state

    Returns void

destroy

  • destroy this shader objects resources (program, attributes, uniforms)

    Returns void

getAttribLocation

  • getAttribLocation(name: string): number

    returns the location of an attribute variable in this shader program

    Parameters

    • name: string

      the name of the attribute variable whose location to get.

    Returns number

    number indicating the location of the variable name if found. Returns -1 otherwise

setUniform

  • setUniform(name: string, value: object | Float32Array<ArrayBufferLike>): void

    Set the uniform to the given value

    Parameters

    • name: string

      the uniform name

    • value: object | Float32Array<ArrayBufferLike>

      the value to assign to that uniform

    Returns void

setVertexAttributes

  • activate the given vertex attribute for this shader

    Parameters

    • gl: WebGLRenderingContext

      the current WebGL rendering context

    • attributes: object[]

      an array of vertex attributes

    • stride: number

      the size of a single vertex in bytes

    Returns void