docs: function CardboardDistorter(gl, cardboardUI, bufferScale, dirtySubmitFrameBindings) {
    this.gl = gl;
    this.cardboardUI = cardboardUI;
    this.bufferScale = bufferScale;
    this.dirtySubmitFrameBindings = dirtySubmitFrameBindings;
    this.ctxAttribs = gl.getContextAttributes();
  
    this.meshWidth = 20;
    this.meshHeight = 20;
  
  
    this.bufferWidth = gl.drawingBufferWidth;
    this.bufferHeight = gl.drawingBufferHeight;
  
    // Patching support
    this.realBindFramebuffer = gl.bindFramebuffer;
    this.realEnable = gl.enable;
    this.realDisable = gl.disable;
    this.realColorMask = gl.colorMask;
    this.realClearColor = gl.clearColor;
    this.realViewport = gl.viewport;
  
    if (!Util.isIOS()) {
      this.realCanvasWidth = Object.getOwnPropertyDescriptor(gl.canvas.__proto__, 'width');
      this.realCanvasHeight = Object.getOwnPropertyDescriptor(gl.canvas.__proto__, 'height');
    }
  
    this.isPatched = false;
  
    // State tracking
    this.lastBoundFramebuffer = null;
    this.cullFace = false;
    this.depthTest = false;
    this.blend = false;
    this.scissorTest = false;
    this.stencilTest = false;
    this.viewport = [0, 0, 0, 0];
    this.colorMask = [true, true, true, true];
    this.clearColor = [0, 0, 0, 0];
  
    this.attribs = {
      position: 0,
      texCoord: 1
    };
    this.program = Util.linkProgram(gl, distortionVS, distortionFS, this.attribs);
    this.uniforms = Util.getProgramUniforms(gl, this.program);
  
    this.viewportOffsetScale = new Float32Array(8);
    this.setTextureBounds();
  
    this.vertexBuffer = gl.createBuffer();
    this.indexBuffer = gl.createBuffer();
    this.indexCount = 0;
  
    this.renderTarget = gl.createTexture();
    this.framebuffer = gl.createFramebuffer();
  
    this.depthStencilBuffer = null;
    this.depthBuffer = null;
    this.stencilBuffer = null;
  
    if (this.ctxAttribs.depth && this.ctxAttribs.stencil) {
      this.depthStencilBuffer = gl.createRenderbuffer();
    } else if (this.ctxAttribs.depth) {
      this.depthBuffer = gl.createRenderbuffer();
    } else if (this.ctxAttribs.stencil) {
      this.stencilBuffer = gl.createRenderbuffer();
    }
  
    this.patch();
  
    this.onResize();
  }