melonJS
    Preparing search index...

    Class Batcher

    Backend-neutral base class for renderer batchers.

    A batcher accumulates vertices into a CPU staging buffer and turns them into GPU work in batches — one draw call for many shapes/sprites. This class defines the lifecycle contract shared by every backend:

    • init(renderer, settings) — build (or rebuild after a context/device loss) the batcher's GPU-facing state; called by the constructor
    • bind() / unbind() — the renderer switches the active batcher
    • flush() — turn the pending vertices into GPU work
    • reset() — drop transient state (game reset / context restore)
    • destroy() — release every GPU resource the batcher owns

    Custom batchers extend the class matching the renderer they target — WebGLBatcher for the WebGL renderer, WebGPUBatcher for the WebGPU renderer — and are registered through renderer.addBatcher(), which accepts any Batcher subclass.

    Hierarchy (View Summary)

    Index
    renderer: Renderer | undefined

    the renderer this batcher is bound to

    • Initialize (or re-initialize after a context/device loss) this batcher. Derived classes override this with their full (renderer, settings) signature and own the whole body; the base implementation only stores the renderer reference.

      Parameters

      • renderer: Renderer

        the owning renderer

      Returns void