src/shaders/GpuShader.js
function (gl, shaderType, shaderSource) {
            if (!(shaderType === gl.VERTEX_SHADER
                || shaderType === gl.FRAGMENT_SHADER)) {
                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "The specified shader type is unrecognized."));
            }

            if (!shaderSource) {
                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "The specified shader source is null or undefined."));
            }

            var shader = gl.createShader(shaderType);
            if (!shader) {
                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "Unable to create shader of type " +
                    (shaderType == gl.VERTEX_SHADER ? "VERTEX_SHADER." : "FRAGMENT_SHADER.")));
            }

            if (!this.compile(gl, shader, shaderType, shaderSource)) {
                var infoLog = gl.getShaderInfoLog(shader);

                gl.deleteShader(shader);

                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "Unable to compile shader: " + infoLog));
            }

            this.shaderId = shader;
        }
function (gl, shaderType, shaderSource) {
            if (!(shaderType === gl.VERTEX_SHADER
                || shaderType === gl.FRAGMENT_SHADER)) {
                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "The specified shader type is unrecognized."));
            }

            if (!shaderSource) {
                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "The specified shader source is null or undefined."));
            }

            var shader = gl.createShader(shaderType);
            if (!shader) {
                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "Unable to create shader of type " +
                    (shaderType == gl.VERTEX_SHADER ? "VERTEX_SHADER." : "FRAGMENT_SHADER.")));
            }

            if (!this.compile(gl, shader, shaderType, shaderSource)) {
                var infoLog = gl.getShaderInfoLog(shader);

                gl.deleteShader(shader);

                throw new ArgumentError(Logger.logMessage(Logger.LEVEL_SEVERE, "GpuShader", "constructor",
                    "Unable to compile shader: " + infoLog));
            }

            this.shaderId = shader;
        }
function ( gl , shaderType , shaderSource ) { if ( ! ( shaderType === gl . VERTEX_SHADER || shaderType === gl . FRAGMENT_SHADER ) ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "GpuShader" , "constructor" , "The specified shader type is unrecognized." ) ) ; } if ( ! shaderSource ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "GpuShader" , "constructor" , "The specified shader source is null or undefined." ) ) ; } var shader = gl . createShader ( shaderType ) ; if ( ! shader ) { throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "GpuShader" , "constructor" , "Unable to create shader of type " + ( shaderType == gl . VERTEX_SHADER ? "VERTEX_SHADER." : "FRAGMENT_SHADER." ) ) ) ; } if ( ! this . compile ( gl , shader , shaderType , shaderSource ) ) { var infoLog = gl . getShaderInfoLog ( shader ) ; gl . deleteShader ( shader ) ; throw new ArgumentError ( Logger . logMessage ( Logger . LEVEL_SEVERE , "GpuShader" , "constructor" , "Unable to compile shader: " + infoLog ) ) ; } this . shaderId = shader ; }
Constructs a GPU shader of a specified type with specified GLSL source code.

@alias GpuShader
@constructor
@classdesc
Represents an OpenGL shading language (GLSL) shader and provides methods for compiling and disposing
of them.

@param {WebGLRenderingContext} gl The current WebGL context.
@param {Number} shaderType The type of shader, either WebGLRenderingContext.VERTEX_SHADER
or WebGLRenderingContext.FRAGMENT_SHADER.
@param {String} shaderSource The shader's source code.
@throws {ArgumentError} If the shader type is unrecognized, the shader source is null or undefined or shader
compilation fails. If the compilation fails the error thrown contains any compilation messages.
Constructs a GPU shader of a specified type with specified GLSL source code .