06-fun/scripts/06-02-modelloader.js
/**
 * Loads and compiles a given shader as the given type.
 * @param type WebGL shader type to load (gl.VERTEX_SHADER | gl.FRAGMENT_SHADER)
 * @param shaderSrc String source of the shader to load
 * @return Fully compiled shader, or null on error
 */
Loads and compiles a given shader as the given type.
@param type WebGL shader type to load (gl.VERTEX_SHADER | gl.FRAGMENT_SHADER)
@param shaderSrc String source of the shader to load
@return Fully compiled shader, or null on error
Loads and compiles a given shader as the given type . @param type WebGL shader type to load ( gl . VERTEX_SHADER | gl . FRAGMENT_SHADER ) @param shaderSrc String source of the shader to load @return Fully compiled shader or null on error
function loadShader(type, shaderSrc) {
    var shader = gl.createShader(type);
    gl.shaderSource(shader, shaderSrc);
    gl.compileShader(shader);
    if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS) &&
        !gl.isContextLost()) {
        var infoLog = gl.getShaderInfoLog(shader);
        window.console.log("Error compiling shader:\n" + infoLog);
        gl.deleteShader(shader);
        return null;
    }
    return shader;
}
function loadShader ( type , shaderSrc ) { var shader = gl . createShader ( type ) ; gl . shaderSource ( shader , shaderSrc ) ; gl . compileShader ( shader ) ; if ( ! gl . getShaderParameter ( shader , gl . COMPILE_STATUS ) && ! gl . isContextLost ( ) ) { var infoLog = gl . getShaderInfoLog ( shader ) ; window . console . log ( "Error compiling shader:\n" + infoLog ) ; gl . deleteShader ( shader ) ; return null ; } return shader ; }
Loads and compiles a given shader as the given type.
Loads and compiles a given shader as the given type .
// Load the shader source // Compile the shader // Check the compile status