Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2016-0-4 21:22

Class enchant.gl.Shader

Class Summary
Constructor Attributes Constructor Name and Description
 
enchant.gl.Shader(vshader, fshader)
Class to control WebGL shader program.
Field Summary
Field Attributes Field Name and Description
 
Fragment shader source
 
Vertex shader source

Method Summary

Method Attributes Method Name and Description
 
Compile shader program.
 
Destroy object.
 
setAttributes(params)
Sets attribute variables to shader program.
 
setUniforms(params)
Set uniform variables to shader program.
 
use()
Set shader program to be used.

Class Detail

enchant.gl.Shader(vshader, fshader)
Class to control WebGL shader program. A shader program will be created by delivering the vertex shader source and fragment shader source.
Parameters:
{String} vshader
Vertex shader source
{String} fshader
Fragment shader source

Field Detail

{String} fShaderSource
Fragment shader source
{String} vShaderSource
Vertex shader source

Method Detail

  • compile()
    Compile shader program. Will be automatically compiled when shader source is delivered from constructor.
    var shader = new Shader();
    // Deliver shader program source.
    shader.vShaderSource = vert;
    shader.fShaderSource = frag;
    // Compile.
    shader.compile();
  • destroy()
    Destroy object.
  • setAttributes(params)
    Sets attribute variables to shader program. Used in enchant.gl.Sprite3D contents and elsewhere.
    var shader = new Shader(vert, frag);
    shader.setAttributes({
        aVertexPosition: indices,
        aNormal: normals
    });
    Parameters:
    {*} params
    Level
  • setUniforms(params)
    Set uniform variables to shader program. Used in enchant.gl.Sprite3D and elsewhere.
    var shader = new Shader(vert, frag);
    shader.setUniforms({
        uDiffuse: diffuse,
        uLightColor: lightColor
    });
    Parameters:
    {*} params
    Level
  • use()
    Set shader program to be used.