Initializiation

Initialization happens just once when the HTML finishes loading. This function is invoked by the onload event on the <body> element.

〈Initialization〉 ≡
  var canvas
  var gl

  function init()
    〈Initialize the GL context
    〈Initialize the program object
    〈Initialize the buffer objects

    〈Copy vertex data to the GPU
    〈Copy triangle data to the GPU

    Request the first animation frame.

These are all that tasks that should be performed exactly once.