init(frameState) {
    const gl = this.getGL();
    const textureSize = [
      gl.drawingBufferWidth * this.scaleRatio_,
      gl.drawingBufferHeight * this.scaleRatio_,
    ];

    // rendering goes to my buffer
    gl.bindFramebuffer(gl.FRAMEBUFFER, this.getFrameBuffer());
    gl.viewport(0, 0, textureSize[0], textureSize[1]);

    // if size has changed: adjust canvas & render target texture
    if (
      !this.renderTargetTextureSize_ ||
      this.renderTargetTextureSize_[0] !== textureSize[0] ||
      this.renderTargetTextureSize_[1] !== textureSize[1]
    ) {
      this.renderTargetTextureSize_ = textureSize;

      // create a new texture
      const level = 0;
      const internalFormat = gl.RGBA;
      const border = 0;
      const format = gl.RGBA;
      const type = gl.UNSIGNED_BYTE;
      const data = null;
      gl.bindTexture(gl.TEXTURE_2D, this.renderTargetTexture_);
      gl.texImage2D(
        gl.TEXTURE_2D,
        level,
        internalFormat,
        textureSize[0],
        textureSize[1],
        border,
        format,
        type,
        data
      );

      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

      // bind the texture to the framebuffer
      gl.framebufferTexture2D(
        gl.FRAMEBUFFER,
        gl.COLOR_ATTACHMENT0,
        gl.TEXTURE_2D,
        this.renderTargetTexture_,
        0
      );
    }
  }
/**
   * Initialize the render target texture of the post process, make sure it is at the
   * right size and bind it as a render target for the next draw calls.
   * The last step to be initialized will be the one where the primitives are rendered.
   * @param {import("../PluggableMap.js").FrameState} frameState current frame state
   * @api
   */
Initialize the render target texture of the post process, make sure it is at the
right size and bind it as a render target for the next draw calls.
The last step to be initialized will be the one where the primitives are rendered.
@param {import("../PluggableMap.js").FrameState} frameState current frame state
@api
Initialize the render target texture of the post process make sure it is at the right size and bind it as a render target for the next draw calls . The last step to be initialized will be the one where the primitives are rendered . @param { import ( " .. / PluggableMap . js " ) . FrameState } frameState current frame state @api
init(frameState) {
    const gl = this.getGL();
    const textureSize = [
      gl.drawingBufferWidth * this.scaleRatio_,
      gl.drawingBufferHeight * this.scaleRatio_,
    ];
    gl.bindFramebuffer(gl.FRAMEBUFFER, this.getFrameBuffer());
    gl.viewport(0, 0, textureSize[0], textureSize[1]);
    if (
      !this.renderTargetTextureSize_ ||
      this.renderTargetTextureSize_[0] !== textureSize[0] ||
      this.renderTargetTextureSize_[1] !== textureSize[1]
    ) {
      this.renderTargetTextureSize_ = textureSize;
      const level = 0;
      const internalFormat = gl.RGBA;
      const border = 0;
      const format = gl.RGBA;
      const type = gl.UNSIGNED_BYTE;
      const data = null;
      gl.bindTexture(gl.TEXTURE_2D, this.renderTargetTexture_);
      gl.texImage2D(
        gl.TEXTURE_2D,
        level,
        internalFormat,
        textureSize[0],
        textureSize[1],
        border,
        format,
        type,
        data
      );
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
      gl.framebufferTexture2D(
        gl.FRAMEBUFFER,
        gl.COLOR_ATTACHMENT0,
        gl.TEXTURE_2D,
        this.renderTargetTexture_,
        0
      );
    }
  }
init ( frameState ) { const gl = this . getGL ( ) ; const textureSize = [ gl . drawingBufferWidth * this . scaleRatio_ , gl . drawingBufferHeight * this . scaleRatio_ , ] ; gl . bindFramebuffer ( gl . FRAMEBUFFER , this . getFrameBuffer ( ) ) ; gl . viewport ( 0 , 0 , textureSize [ 0 ] , textureSize [ 1 ] ) ; if ( ! this . renderTargetTextureSize_ || this . renderTargetTextureSize_ [ 0 ] !== textureSize [ 0 ] || this . renderTargetTextureSize_ [ 1 ] !== textureSize [ 1 ] ) { this . renderTargetTextureSize_ = textureSize ; const level = 0 ; const internalFormat = gl . RGBA ; const border = 0 ; const format = gl . RGBA ; const type = gl . UNSIGNED_BYTE ; const data = null ; gl . bindTexture ( gl . TEXTURE_2D , this . renderTargetTexture_ ) ; gl . texImage2D ( gl . TEXTURE_2D , level , internalFormat , textureSize [ 0 ] , textureSize [ 1 ] , border , format , type , data ) ; gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MIN_FILTER , gl . LINEAR ) ; gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_S , gl . CLAMP_TO_EDGE ) ; gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_T , gl . CLAMP_TO_EDGE ) ; gl . framebufferTexture2D ( gl . FRAMEBUFFER , gl . COLOR_ATTACHMENT0 , gl . TEXTURE_2D , this . renderTargetTexture_ , 0 ) ; } }
Initialize the render target texture of the post process, make sure it is at the
 right size and bind it as a render target for the next draw calls.
Initialize the render target texture of the post process make sure it is at the right size and bind it as a render target for the next draw calls .
// rendering goes to my buffer // if size has changed: adjust canvas & render target texture // create a new texture // bind the texture to the framebuffer