pixi.js
    Preparing search index...

    Class GpuRenderTargetSystemAdvanced

    The WebGL adaptor for the render target system. Allows the Render Target System to be used with the WebGl renderer

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    adaptor: GpuRenderTargetAdaptor = ...

    a reference to the adaptor that interfaces with WebGL / WebGP

    defaultClearColor: RgbaArray = ...

    the default clear color for render targets

    onRenderTargetChange: SystemRunner = ...

    a runner that lets systems know if the active render target has changed. Eg the Stencil System needs to know so it can manage the stencil buffer

    projectionMatrix: Matrix = ...

    the projection matrix that is used by the shaders based on the active render target and the viewport

    renderingToScreen: boolean

    A boolean that lets the dev know if the current render pass is rendering to the screen. Used by some plugins

    renderSurface: RenderSurface

    the current active render surface that the render target is created from

    renderTarget: RenderTarget

    the current active render target

    rootRenderTarget: RenderTarget

    When rendering of a scene begins, this is where the root render surface is stored

    rootViewPort: Rectangle = ...

    This is the root viewport for the render pass

    viewport: Rectangle = ...

    the current viewport that the gpu is using

    Methods

    • Binding a render surface! This is the main function of the render target system. It will take the RenderSurface (which can be a texture, canvas, or render target) and bind it to the renderer. Once bound all draw calls will be rendered to the render surface.

      If a frame is not provide and the render surface is a texture, the frame of the texture will be used.

      Parameters

      • renderSurface: RenderSurface

        the render surface to bind

      • clear: CLEAR_OR_BOOL = true

        the clear mode to use. Can be true or a CLEAR number 'COLOR | DEPTH | STENCIL' 0b111

      • OptionalclearColor: RgbaArray

        the color to clear to

      • Optionalframe: Rectangle

        the frame to render to

      Returns RenderTarget

      the render target that was bound

    • Copies a render surface to another texture.

      NOTE: for sourceRenderSurfaceTexture, The render target must be something that is written too by the renderer

      The following is not valid:

      Parameters

      • sourceRenderSurfaceTexture: RenderTarget

        the render surface to copy from

      • destinationTexture: Texture

        the texture to copy to

      • originSrc: { x: number; y: number }

        the origin of the copy

        • x: number

          the x origin of the copy

        • y: number

          the y origin of the copy

      • size: { height: number; width: number }

        the size of the copy

        • height: number

          the height of the copy

        • width: number

          the width of the copy

      • originDest: { x: number; y: number }

        the destination origin (top left to paste from!)

        • x: number

          the x origin of the paste

        • y: number

          the y origin of the paste

      Returns Texture<TextureSource<any>>

      const canvas = document.createElement('canvas')
      canvas.width = 200;
      canvas.height = 200;

      const ctx = canvas2.getContext('2d')!
      ctx.fillStyle = 'red'
      ctx.fillRect(0, 0, 200, 200);

      const texture = RenderTexture.create({
      width: 200,
      height: 200,
      })
      const renderTarget = renderer.renderTarget.getRenderTarget(canvas2);

      renderer.renderTarget.copyToTexture(renderTarget,texture, {x:0,y:0},{width:200,height:200},{x:0,y:0});

      The best way to copy a canvas is to create a texture from it. Then render with that.

      Parsing in a RenderTarget canvas context (with a 2d context)
    • ensures that we have a depth stencil buffer available to render to This is used by the mask system to make sure we have a stencil buffer.

      Returns void

    • Gets the render target from the provide render surface. Eg if its a texture, it will return the render target for the texture. If its a render target, it will return the same render target.

      Parameters

      • renderSurface: RenderSurface

        the render surface to get the render target for

      Returns RenderTarget

      the render target for the render surface

    • Pops the current render target from the renderer and restores the previous render target.

      Returns void

    • Push a render surface to the renderer. This will bind the render surface to the renderer,

      Parameters

      • renderSurface: RenderSurface

        the render surface to push

      • clear: boolean | CLEAR = CLEAR.ALL

        the clear mode to use. Can be true or a CLEAR number 'COLOR | DEPTH | STENCIL' 0b111

      • OptionalclearColor: RgbaArray

        the color to clear to

      • Optionalframe: Rectangle

        the frame to use when rendering to the render surface

      Returns RenderTarget