constructor(canvas=undefined, context=undefined) {
        if (canvas === undefined) {
            canvas = /** @type {!HTMLCanvasElement} */ document.createElement('canvas');
            context = undefined;
        }
        if (context === undefined) {
            context = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
        }

        /**
         * A hidden canvas backing the WglContext.
         * @type {!HTMLCanvasElement}
         */
        this.canvas = canvas;

        /**
         * The WebGLRenderingContext instance associated with the WglContext.
         * @type {!WebGLRenderingContext}
         */
        this.gl = context;

        if ((/** @type {null|!WebGLRenderingContext} */ this.gl) === null) {
            throw new Error('Error creating WebGL context.');
        }
        if (this.gl.getExtension('OES_texture_float') === undefined) {
            // We'll just fall back to using byte coding of intermediate values.
            console.warn("OES_texture_float webgl extension not present.");
        }
        if (this.gl.getExtension('WEBGL_color_buffer_float') === undefined) {
            // We'll just fall back to using byte coding of intermediate values.
            console.warn("WEBGL_color_buffer_float webgl extension not present.");
        }

        /** @type {!function():void} */
        this.onContextRestored = undefined;

        /**
         * Changed when the wrapped WebGLRenderingContext is lost/restored and things need to be re-created.
         * @type {!int}
         */
        this.lifetimeCounter = 0;

        // Wire lifetime updates.
        this.canvas.addEventListener(
            "webglcontextrestored",
            event => {
                event.preventDefault();
                this.recomputeProperties();
                if (this.onContextRestored !== undefined) {
                    this.onContextRestored();
                }
            },
            false);
        this.canvas.addEventListener(
            'webglcontextlost',
            event => {
                event.preventDefault();
                this.lifetimeCounter++;
            },
            false);

        this.recomputeProperties();
    }
Creates and wraps a WebGLRenderingContext.
@param {!HTMLCanvasElement} canvas
@param {!WebGLRenderingContext} context