Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SpriteBatchRenderer

Hierarchy

  • BatchRenderer
    • SpriteBatchRenderer

Index

Constructors

constructor

Properties

MAX_TEXTURES

MAX_TEXTURES: 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.AbstractBatchRenderer#contextChange

readonly

Protected _aBuffers

_aBuffers: ViewableBuffer[]

Pool of ViewableBuffer objects that are sorted in order of increasing size. The flush method uses the buffer with the least size above the amount it requires. These are used for passing attributes.

The first buffer has a size of 8; each subsequent buffer has double capacity of its previous.

member

{PIXI.ViewableBuffer[]}

see

PIXI.AbstractBatchRenderer#getAttributeBuffer

Protected _aIndex

_aIndex: number

Protected _attributeBuffer

_attributeBuffer: ViewableBuffer

Protected _bufferSize

_bufferSize: number

Number of elements that are buffered and are waiting to be flushed.

Protected _bufferedElements

_bufferedElements: IBatchableElement[]

Buffer of objects that are yet to be rendered.

member

{PIXI.DisplayObject[]}

Protected _bufferedTextures

_bufferedTextures: BaseTexture<Resource, IAutoDetectOptions>[]

Data for texture batch builder, helps to save a bit of CPU on a pass.

member

{PIXI.BaseTexture[]}

Protected _dcIndex

_dcIndex: number

Protected _flushId

_flushId: number

A flush may occur multiple times in a single frame. On iOS devices or when settings.CAN_UPLOAD_SAME_BUFFER is false, the batch renderer does not upload data to the same WebGLBuffer for performance reasons.

This is the index into packedGeometries that points to geometry holding the most recent buffers.

Protected _iBuffers

_iBuffers: Uint16Array[]

Pool of Uint16Array objects that are sorted in order of increasing size. The flush method uses the buffer with the least size above the amount it requires. These are used for passing indices.

The first buffer has a size of 12; each subsequent buffer has double capacity of its previous.

member

{Uint16Array[]}

see

PIXI.AbstractBatchRenderer#getIndexBuffer

Protected _iIndex

_iIndex: number

Protected _indexBuffer

_indexBuffer: Uint16Array

Protected _indexCount

_indexCount: number

Total count of all indices used by the currently buffered objects.

Protected _shader

_shader: Shader

This shader is generated by this.shaderGenerator.

It is generated specifically to handle the required number of textures being batched together.

Protected _tempBoundTextures

_tempBoundTextures: BaseTexture<Resource, IAutoDetectOptions>[]

Protected _vertexCount

_vertexCount: number

Total count of all vertices used by the currently buffered objects.

Protected geometryClass

geometryClass: typeof BatchGeometry

The class that represents the geometry of objects that are going to be batched with this.

member

{object}

default

PIXI.BatchGeometry

Protected renderer

renderer: Renderer

The renderer this manager works for.

Protected shaderGenerator

shaderGenerator: BatchShaderGenerator

This is used to generate a shader that can color each vertex based on a aTextureId attribute that points to an texture in uSampler.

This enables the objects with different textures to be drawn in the same draw call.

You can customize your shader by creating your custom shader generator.

size

size: number

The number of bufferable objects before a flush occurs automatically.

default

settings.SPRITE_BATCH_SIZE * 4

Readonly state

state: State

The WebGL state in which this renderer will work.

Protected vertexSize

vertexSize: number

Size of data being buffered per vertex in the attribute buffers (in floats). By default, the batch-renderer plugin uses 6:

aVertexPosition 2
aTextureCoords 2
aColor 1
aTextureId 1
readonly

Static _drawCallPool

_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

{PIXI.BatchDrawCall[]}

Static _textureArrayPool

_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

{PIXI.BatchTextureArray[]}

Methods

bindAndClearTexArray

  • bindAndClearTexArray(texArray: BatchTextureArray): void
  • Bind textures for current rendering

    Parameters

    • texArray: BatchTextureArray

    Returns void

buildDrawCalls

  • buildDrawCalls(texArray: BatchTextureArray, start: number, finish: number): void
  • Populating drawcalls for rendering

    Parameters

    • texArray: BatchTextureArray
    • start: number
    • finish: number

    Returns void

buildTexturesAndDrawCalls

  • buildTexturesAndDrawCalls(): void
  • Returns void

contextChange

  • contextChange(): void
  • Handles the contextChange signal.

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

    Returns void

destroy

  • destroy(): void
  • Destroys this AbstractBatchRenderer. It cannot be used again.

    Returns void

drawBatches

  • drawBatches(): void
  • Returns void

flush

  • flush(): void
  • Renders the content now and empties the current batch.

    Returns void

getAttributeBuffer

  • getAttributeBuffer(size: number): ViewableBuffer
  • 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

getIndexBuffer

  • getIndexBuffer(size: number): Uint16Array
  • 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.

initFlushBuffers

  • initFlushBuffers(): void
  • Makes sure that static and dynamic flush pooled objects have correct dimensions.

    Returns void

onPrerender

  • onPrerender(): void
  • Handles the prerender signal. It ensures that flushes start from the first geometry object again.

    Returns void

packInterleavedGeometry

  • packInterleavedGeometry(element: IBatchableElement, attributeBuffer: ViewableBuffer, indexBuffer: Uint16Array, aIndex: number, iIndex: number): void
  • Parameters

    • element: IBatchableElement
    • attributeBuffer: ViewableBuffer
    • indexBuffer: Uint16Array
    • aIndex: number
    • iIndex: number

    Returns void

render

  • render(element: IBatchableElement): void
  • Buffers the "batchable" object. It need not be rendered immediately.

    Parameters

    • element: IBatchableElement

      the element to render when using this renderer

    Returns void

start

  • start(): void
  • Starts a new sprite batch.

    Returns void

stop

  • stop(): void
  • Stops and flushes the current batch.

    Returns void

updateGeometry

  • updateGeometry(): void
  • Returns void

Generated using TypeDoc