Class: Shader

Palette. Shader

Abstraction of shader references to allow easy manipulation.

new Shader(gl, name, type, source, gl, attrs)

Initialise and compile a valid Source Object into a Shader.
Parameters:
Name Type Argument Description
gl WebGLRenderingContext The context the shader will belong to and be compiled by.
name string The name the shader object will be referred to by.
type number The class of the shader contained, either Palette.Shader.VS or Palette.Shader.FS.
source string The source code to compile the shader from.
gl WebGLRenderingContext The context the shaders of this program will belong to and be compiled by.
attrs object <optional>
The array which contains attribute names and default values, as an array of 3-tuples.
Author:
  • FelixMcFelix (Kyle S.)
Source:

Members

<protected, readonly> attrs :Array[]

The shader's attribute array.
Type:
  • Array[]
Source:

<protected, readonly> context :WebGLRenderingContext

The shader's attached context.
Type:
  • WebGLRenderingContext
Source:

<protected, readonly> name :String

The shader's name.
Type:
  • String
Source:

<protected, readonly> shader :WebGLShader

The reference to the compiled shader in the WebGLRenderingContext.
Type:
  • WebGLShader
Source:

<protected, readonly> type :int

The type of shader, either Palette.Shader.VS or Palette.Shader.FS for objects.
Type:
  • int
Source:

Methods

<protected> bakeShader(source) → {boolean}

Compile shader code from a source string. Once compiled, you cannot recompile.
Parameters:
Name Type Description
source string The source code to compile and attach to this shader object.
Source:
Returns:
True if successful, false if unsuccessful.
Type
boolean