src/webgl/createProgramFromString.js
function compileShader (gl, shaderSource, shaderType) {

  // Create the shader object
  const shader = gl.createShader(shaderType);

  // Set the shader source code.
  gl.shaderSource(shader, shaderSource);

  // Compile the shader
  gl.compileShader(shader);

  // Check if it compiled
  const success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);

  if (!success && !gl.isContextLost()) {
    // Something went wrong during compilation; get the error
    const infoLog = gl.getShaderInfoLog(shader);

    console.error(`Could not compile shader:\n${infoLog}`);
  }

  return shader;
}
function compileShader (gl, shaderSource, shaderType) {

  // Create the shader object
  const shader = gl.createShader(shaderType);

  // Set the shader source code.
  gl.shaderSource(shader, shaderSource);

  // Compile the shader
  gl.compileShader(shader);

  // Check if it compiled
  const success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);

  if (!success && !gl.isContextLost()) {
    // Something went wrong during compilation; get the error
    const infoLog = gl.getShaderInfoLog(shader);

    console.error(`Could not compile shader:\n${infoLog}`);
  }

  return shader;
}
function compileShader ( gl , shaderSource , shaderType ) { // Create the shader object const shader = gl . createShader ( shaderType ) ; // Set the shader source code. gl . shaderSource ( shader , shaderSource ) ; // Compile the shader gl . compileShader ( shader ) ; // Check if it compiled const success = gl . getShaderParameter ( shader , gl . COMPILE_STATUS ) ; if ( ! success && ! gl . isContextLost ( ) ) { // Something went wrong during compilation; get the error const infoLog = gl . getShaderInfoLog ( shader ) ; console . error ( ` \n ${ infoLog } ` ) ; } return shader ; }
Creates and compiles a shader.

@param {!WebGLRenderingContext} gl The WebGL Context.
@param {string} shaderSource The GLSL source code for the shader.
@param {number} shaderType The type of shader, VERTEX_SHADER or FRAGMENT_SHADER.

@return {!WebGLShader} The shader.
@memberof WebGLRendering
Creates and compiles a shader .