Class: Shader

Shader


new Shader(shaderManager [, vertexSrc] [, fragmentSrc] [, uniforms] [, attributes])

Base shader class for PIXI managed shaders.

Parameters:
Name Type Argument Description
shaderManager ShaderManager

The webgl shader manager this shader works for.

vertexSrc string <optional>

The source of the vertex shader.

fragmentSrc string <optional>

The source of the fragment shader.

uniforms object <optional>

Uniforms for this shader.

attributes object <optional>

Attributes for this shader.

Source:

Members


fragmentSrc :string

The fragment shader as an array of strings

Type:
  • string
Source:

<readonly> gl :WebGLRenderingContext

The current WebGL drawing context

Type:
  • WebGLRenderingContext
Source:

<readonly> program :WebGLProgram

The WebGL program.

Type:
  • WebGLProgram
Source:

<readonly> uid :number

A unique id

Type:
  • number
Source:

vertexSrc :string

The vertex shader as an array of strings

Type:
  • string
Source:

Methods


cacheAttributeLocations(keys)

Caches the locations of the attribute for reuse.

Parameters:
Name Type Description
keys string

the attributes to cache

Source:

cacheUniformLocations(keys)

Caches the locations of the uniform for reuse.

Parameters:
Name Type Description
keys string

the uniforms to cache

Source:

compile()

Attaches the shaders and creates the program.

Source:
Returns:
Type
WebGLProgram

destroy()

Destroys the shader.

Source:

init()

Creates the shader and uses it

Source:

initSampler2D()

Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded)

Source:

syncUniform(uniform)

Adds a new uniform

Parameters:
Name Type Description
uniform object

the new uniform to attach

Source:

syncUniforms()

Updates the shader uniform values.

Source: