me.GLShader(gl, vertex, fragment, precisionopt)

new GLShader(gl, vertex, fragment, precisionopt)

a base GL Shader object

Parameters:
Name Type Attributes Default Description
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

precision String <optional>
auto detected

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

See:
Example
// create a basic shader
var myShader = new me.GLShader(
   // WebGL rendering context
   gl,
   // vertex shader
   [
       "void main() {",
       "    gl_Position = doMathToMakeClipspaceCoordinates;",
       "}"
   ].join("\n"),
   // fragment shader
   [
       "void main() {",
       "    gl_FragColor = doMathToMakeAColor;",
       "}"
   ].join("\n")
 )
// use the shader
myShader.bind();

Extends

Members

static attributes :Object

the attributes of the shader

static gl :WebGLRenderingContext

the active gl rendering context

static program :WebGLProgram

a reference to the shader program (once compiled)

static uniforms :Object

the uniforms of the shader

static vertex :String

the vertex shader source code

static vertex :String

the fragment shader source code

Methods

static bind()

Installs this shader program as part of current rendering state

static destroy()

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