1.2.1_preparing_to_render_in_3D - MartijnKeesmaat/WebGL-practice GitHub Wiki

Code

Steps

  1. Get the reference of the DOM node and set the context
const canvas = document.querySelector('#glCanvas');
// Init GL context
const gl = canvas.getContext('webgl');
  1. Check if the context is initialized correctly
if (gl === null) {
  alert('WebGl isn\'t working');
  return;
}

Source