function setupWebGL(canvas, optAttribs, onError) {
    function showLink(str) {
        var container = canvas.parentNode;
        if (container) {
            container.innerHTML = makeFailHTML(str);
        }
    }

    function handleError(errorCode, msg) {
        if (typeof onError === 'function') {
            onError(errorCode);
        } else {
            showLink(msg);
        }
    }

    if (!window.WebGLRenderingContext) {
        handleError(ERROR_BROWSER_SUPPORT, GET_A_WEBGL_BROWSER);
        return null;
    }

    var context = create3DContext(canvas, optAttribs);
    if (!context) {
        handleError(ERROR_OTHER, OTHER_PROBLEM);
    } else {
        context.getExtension('OES_standard_derivatives');
    }
    return context;
}
Creates a webgl context. If creation fails it will
change the contents of the container of the <canvas>
tag to an error message with the correct links for WebGL,
unless `onError` option is defined to a callback,
which allows for custom error handling..
@param {Element} canvas. The canvas element to create a
    context from.
@param {WebGLContextCreationAttributes} optAttribs Any
    creation attributes you want to pass in.
@return {WebGLRenderingContext} The created context.