Initializing WebGL

WebGL uses a context

let canvas = undefined;  // HTML <canvas> element
let gl = undefined;      // WebGL context

function init() {
    // Find our <canvas> element in the HTML document
    canvas = document.getElementById("webgl-canvas");
    if (!canvas) { alert("Unable to find WebGL canvas"); }

    // Have the canvas create a WebGL2 context for us
    gl = canvas.getContext("webgl2");
    if (!gl) { alert("WebGL2 isn't supported"); }

    // At this point, we can use WebGL
    //   so let's set the color to clear our window
    gl.clearColor(0.25, 0.25, 0.25, 1.0);

    // Lots more stuff to come ...
}

// Start our application when the HTML page loads
window.onload = init();