called by the renderer when this batcher becomes the current one
release every GPU resource this batcher owns
turn the pending vertices into GPU work
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 and ignores the settings.
settings is declared here even though this body does not read it: a
subclass cannot add a required parameter the base does not have without
breaking substitutability, and the backends all take one.
the owning renderer
Optionalsettings: object
backend-specific batcher settings, owned and documented by the derived class
reset the batcher's transient state (game reset / context restore)
called by the renderer when this batcher is being replaced by another
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 constructorbind()/unbind()— the renderer switches the active batcherflush()— turn the pending vertices into GPU workreset()— drop transient state (game reset / context restore)destroy()— release every GPU resource the batcher ownsCustom batchers extend the class matching the renderer they target — WebGLBatcher for the WebGL renderer,
WebGPUBatcherfor the WebGPU renderer — and are registered throughrenderer.addBatcher(), which accepts any Batcher subclass.