Options
All
  • Public
  • Public/Protected
  • All
Menu

Class to assemble a Shader to use with WebGL

Hierarchy

  • Shader

Index

Constructors

constructor

  • new Shader(gl: WebGL2RenderingContext, vertexShaderSource: string, fragmentShaderSource: string): Shader
  • Creates a shader

    Parameters

    • gl: WebGL2RenderingContext

      The 3D context

    • vertexShaderSource: string

      The vertex shader source code

    • fragmentShaderSource: string

      The fragment shader source code

    Returns Shader

Properties

Private fragmentShaderSource

fragmentShaderSource: string

The fragment shader source code

Private gl

gl: WebGL2RenderingContext

The 3D context

Private shaderProgram

shaderProgram: WebGLProgram

The WebGL program consisting of the vertex shader and the fragment shader

Private vertexShaderSource

vertexShaderSource: string

The vertex shader source code

Methods

getAttributeLocation

  • getAttributeLocation(name: string): number
  • Returns the attribute location of a variable in the shader program

    Parameters

    • name: string

      The name of the variable

    Returns number

    The variable's location

Private getShader

  • getShader(gl: WebGL2RenderingContext, source: string, type: number): WebGLShader
  • Loads a shader part from its script DOM node and compiles it

    Parameters

    • gl: WebGL2RenderingContext

      The 3D context

    • source: string

      The source code

    • type: number

    Returns WebGLShader

    The resulting shader part

getUniformFloat

  • Returns an object that can be used to set an int on the GPU

    Parameters

    • name: string

      The name of the uniform to set

    Returns UniformFloat

    The resulting object

getUniformInt

  • Returns an object that can be used to set an int on the GPU

    Parameters

    • name: string

      The name of the uniform to set

    Returns UniformInt

    The resulting object

getUniformMatrix

  • Returns an object that can be used to set a matrix on the GPU

    Parameters

    • name: string

      The name of the uniform to set

    Returns UniformMatrix

    The resulting object

getUniformVec3

  • Returns an object that can be used to set a vector on the GPU

    Parameters

    • name: string

      The name of the uniform to set

    Returns UniformVec3

    The resulting object

getUniformVec4

  • Returns an object that can be used to set a vector on the GPU

    Parameters

    • name: string

      The name of the uniform to set

    Returns UniformVec4

    The resulting object

load

  • load(): void
  • Creates and compiles a Shader from the given sources,

    Returns void

use

  • use(): void
  • Use this shader program for the next WebGL calls

    Returns void

Generated using TypeDoc