src/twgl.js
function createContext(canvas, opt_attribs) {
  const names = ["webgl2", "webgl", "experimental-webgl"];
  let context = null;
  for (let ii = 0; ii < names.length; ++ii) {
    context = canvas.getContext(names[ii], opt_attribs);
    if (context) {
      if (defaults.addExtensionsToContext) {
        addExtensionsToContext(context);
      }
      break;
    }
  }
  return context;
}
function createContext(canvas, opt_attribs) {
  const names = ["webgl2", "webgl", "experimental-webgl"];
  let context = null;
  for (let ii = 0; ii < names.length; ++ii) {
    context = canvas.getContext(names[ii], opt_attribs);
    if (context) {
      if (defaults.addExtensionsToContext) {
        addExtensionsToContext(context);
      }
      break;
    }
  }
  return context;
}
function createContext ( canvas , opt_attribs ) { const names = [ "webgl2" , "webgl" , "experimental-webgl" ] ; let context = null ; for ( let ii = 0 ; ii < names . length ; ++ ii ) { context = canvas . getContext ( names [ ii ] , opt_attribs ) ; if ( context ) { if ( defaults . addExtensionsToContext ) { addExtensionsToContext ( context ) ; } break ; } } return context ; }
Creates a webgl context.

Will return a WebGL2 context if possible.

You can check if it's WebGL2 with

twgl.isWebGL2(gl);

@param {HTMLCanvasElement} canvas The canvas tag to get
context from. If one is not passed in one will be
created.
@return {WebGLRenderingContext} The created context.
Creates a webgl context .