WebGLShader

A lower level function to compile either a vertex or fragment shader.

Code Example

const gl = renderer.getContext(); const glVertexShader = new v3d.WebGLShader(gl, gl.VERTEX_SHADER, vertexSourceCode); const glFragmentShader = new v3d.WebGLShader(gl, gl.FRAGMENT_SHADER, fragmentSourceCode); const program = gl.createProgram(); gl.attachShader(program, glVertexShader); gl.attachShader(program, glFragmentShader); gl.linkProgram(program);

Function

objects(gl, type, source)

gl -- The current WebGL context type -- The WebGL type, either gl.VERTEX_SHADER or gl.FRAGMENT_SHADER source -- The source code for the shader

This will compile an individual shader, but won't link it to be a complete WebGLProgram. Note: this is a function so the new operator should not be used.

Source

For more info on how to obtain the source code of this module see this page.