Class: AbstractBatchRenderer

PIXI.AbstractBatchRenderer

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.

new PIXI.AbstractBatchRenderer (renderer) overrides

AbstractBatchRenderer.ts:75

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

Name Type Description
renderer PIXI.Renderer

The renderer this works for.

Extends

Members

PIXI.AbstractBatchRenderer._drawCallPool Array<PIXI.BatchDrawCall> static

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.

PIXI.AbstractBatchRenderer._textureArrayPool Array<PIXI.BatchTextureArray> static

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.

MAX_TEXTURES number readonly

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

Default Value:
  • 1
See:

size number

The number of bufferable objects before a flush occurs automatically.

Default Value:
  • settings.SPRITE_BATCH_SIZE * 4

state PIXI.State readonly

The WebGL state in which this renderer will work.

vertexSize number readonly

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
Default Value:
  • undefined

_shader PIXI.Shader protected

This shader is generated by this.shaderGenerator.

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

Default Value:
  • undefined

geometryClass object protected

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

Default Value:
  • PIXI.BatchGeometry

shaderGenerator PIXI.BatchShaderGenerator protected

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.

Default Value:
  • undefined

Methods

bindAndClearTexArray (texArray) void

AbstractBatchRenderer.ts:513

Bind textures for current rendering

Name Type Description
texArray PIXI.BatchTextureArray

buildDrawCalls (texArray, start, finish) void

AbstractBatchRenderer.ts:451

Populating drawcalls for rendering

Name Type Description
texArray PIXI.BatchTextureArray
start number
finish number

contextChange () void

AbstractBatchRenderer.ts:289

Handles the contextChange signal.

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

destroy () void overrides

AbstractBatchRenderer.ts:641

Destroys this AbstractBatchRenderer. It cannot be used again.

drawBatches () void

AbstractBatchRenderer.ts:564

flush () void overrides

AbstractBatchRenderer.ts:589

Renders the content now and empties the current batch.

initFlushBuffers () void

AbstractBatchRenderer.ts:328

Makes sure that static and dynamic flush pooled objects have correct dimensions

onPrerender () void

AbstractBatchRenderer.ts:356

Handles the prerender signal.

It ensures that flushes start from the first geometry object again.

packInterleavedGeometry (element, attributeBuffer, indexBuffer, aIndex, iIndex) void

AbstractBatchRenderer.ts:732

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.

Name Type Description
element PIXI.Sprite

element being rendered

attributeBuffer PIXI.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

render (element) void overrides

AbstractBatchRenderer.ts:367

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

Name Type Description
element PIXI.DisplayObject

the element to render when using this renderer

start () void overrides

AbstractBatchRenderer.ts:615

Starts a new sprite batch.

stop () void overrides

AbstractBatchRenderer.ts:633

Stops and flushes the current batch.

Inherited Properties

From class PIXI.ObjectRenderer

The renderer this manager works for.