Renderer dedicated to drawing and batching sprites.

This is the default batch renderer. It buffers objects with texture-based geometries and renders them in batches. It uploads multiple textures to the GPU to reduce to the number of draw calls.

Memberof

PIXI

Hierarchy (view full)

Constructors

  • This will hook onto the renderer's contextChange and prerender signals.

    Parameters

    • renderer: Renderer

      The renderer this works for.

    Returns BatchRenderer

Properties

maxTextures: number

Maximum number of textures that can be uploaded to the GPU under the current context. It is initialized properly in this.contextChange.

See

PIXI.BatchRenderer#contextChange

size: number

The number of bufferable objects before a flush occurs automatically.

Default

PIXI.BatchRenderer.defaultBatchSize * 4
state: State

The WebGL state in which this renderer will work.

_drawCallPool: BatchDrawCall[]

Pool of BatchDrawCall objects that flush used to create "batches" of the objects being rendered.

These are never re-allocated again. Shared between all batch renderers because it can be only one "flush" working at the moment.

Member

_textureArrayPool: BatchTextureArray[]

Pool of BatchDrawCall objects that flush used to create "batches" of the objects being rendered.

These are never re-allocated again. Shared between all batch renderers because it can be only one "flush" working at the moment.

Member

defaultBatchSize: number

The default sprite batch size.

The default aims to balance desktop and mobile devices.

Static

Accessors

  • get MAX_TEXTURES(): number
  • Returns number

    See

    PIXI.BatchRenderer#maxTextures

    Deprecated

    since 7.1.0

  • get canUploadSameBuffer(): boolean
  • Can we upload the same buffer in a single frame?

    Returns boolean

    Static

  • set canUploadSameBuffer(value): void
  • Parameters

    • value: boolean

    Returns void

  • get defaultFragmentTemplate(): string
  • The default fragment shader source

    Returns string

  • get defaultMaxTextures(): number
  • The maximum textures that this device supports.

    Returns number

    Static

    Default

    32
    
  • set defaultMaxTextures(value): void
  • Parameters

    • value: number

    Returns void

  • get defaultVertexSrc(): string
  • The default vertex shader source

    Returns string

Methods

  • Bind textures for current rendering

    Parameters

    Returns void

  • Populating drawcalls for rendering

    Parameters

    Returns void

  • Returns void

  • Handles the contextChange signal.

    It calculates this.maxTextures and allocating the packed-geometry object pool.

    Returns void

  • Destroys this BatchRenderer. It cannot be used again.

    Returns void

  • Returns void

  • Renders the content now and empties the current batch.

    Returns void

  • Fetches an attribute buffer from this._aBuffers that can hold atleast size floats.

    Parameters

    • size: number

      minimum capacity required

    Returns ViewableBuffer

    • buffer than can hold atleast size floats
  • Fetches an index buffer from this._iBuffers that can have at least size capacity.

    Parameters

    • size: number

      minimum required capacity

    Returns Uint16Array

    • buffer that can fit size indices.
  • Makes sure that static and dynamic flush pooled objects have correct dimensions.

    Returns void

  • Handles the prerender signal. It ensures that flushes start from the first geometry object again.

    Returns void

  • Takes the four batching parameters of element, interleaves and pushes them into the batching attribute/index buffers given.

    It uses these properties: vertexData uvs, textureId and indicies. It also uses the "tint" of the base-texture, if present.

    Parameters

    • element: IBatchableElement

      element being rendered

    • attributeBuffer: ViewableBuffer

      attribute buffer.

    • indexBuffer: Uint16Array

      index buffer

    • aIndex: number

      number of floats already in the attribute buffer

    • iIndex: number

      number of indices already in indexBuffer

    Returns void

  • Buffers the "batchable" object. It need not be rendered immediately.

    Parameters

    Returns void

  • Set the shader generator.

    Parameters

    • Optional options: {
          fragment?: string;
          vertex?: string;
      }
      • Optional fragment?: string

        Fragment shader template

      • Optional vertex?: string

        Vertex shader source

    Returns void

  • Starts a new sprite batch.

    Returns void

  • Stops and flushes the current batch.

    Returns void

  • Returns void

Generated using TypeDoc