melonJS
    Preparing search index...

    Class RenderTargetAbstract

    Abstract base class for offscreen render targets. Provides a renderer-agnostic interface for binding, clearing, resizing, and reading back pixel data from an offscreen surface. Concrete implementations:

    • WebGLRenderTarget — WebGL framebuffer object (FBO) for post-processing
    • CanvasRenderTarget — 2D canvas surface for texture generation

    A future WebGPU implementation would extend this class with GPUTexture / GPURenderPassDescriptor management.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    height: number

    The height of this render target in pixels.

    width: number

    The width of this render target in pixels.

    Methods

    • Read back pixel data from this render target.

      Parameters

      • Optionalx: number

        x coordinate of the top-left corner (default 0)

      • Optionaly: number

        y coordinate of the top-left corner (default 0)

      • Optionalwidth: number

        width of the area to read (default full width)

      • Optionalheight: number

        height of the area to read (default full height)

      Returns ImageData

      an ImageData object containing the pixel data

    • Creates a Blob object representing the image contained in this render target.

      Parameters

      • type: string = "image/png"

        a string indicating the image format (default "image/png")

      • Optionalquality: number

        a number between 0 and 1 for lossy formats (e.g. image/jpeg)

      Returns Promise<Blob>

      a Promise resolving to a Blob

    • Returns a data URL containing a representation of the current contents.

      Parameters

      • type: string = "image/png"

        a string indicating the image format (default "image/png")

      • Optionalquality: number

        a number between 0 and 1 for lossy formats (e.g. image/jpeg)

      Returns Promise<string>

      a Promise resolving to a data URL string