BatchHandler
A Batch Handler Render Node. This is a base class used for other
Batch Handler Render Nodes.
A batch handler buffers data for a batch of objects to be rendered
together. It is responsible for the vertex buffer layout and shaders
used to render the batched items.
This class is not meant to be used directly, but to be extended by
other classes.
Constructor
new BatchHandler(manager, defaultConfig, [config])
Parameters
| name | type | optional | description |
|---|---|---|---|
| manager | Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager | No | The manager that owns this RenderNode. |
| defaultConfig | Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig | No | The default configuration object for this RenderNode. This is used to ensure all required properties are present, so it must be complete. |
| config | Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig | Yes | The configuration object for this RenderNode. |
Scope: static
Extends
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L13
Since: 4.0.0
Inherited Members
From Phaser.Renderer.WebGL.RenderNodes.RenderNode:
Public Members
batchEntries
batchEntries: Array.<Phaser.Types.Renderer.WebGL.WebGLBatchEntry>
Description:
The entries in the batch.
Each entry represents a "sub-batch" of quads which use the same
pool of textures. This allows the renderer to continue to buffer
quads into the same batch without needing to upload the vertex
buffer. When the batch flushes, there will be one vertex buffer
upload, and one draw call per batch entry.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L232
Since: 4.0.0
bytesPerIndexPerInstance
bytesPerIndexPerInstance: number
Description:
The number of bytes per index per instance.
This is used to advance the index buffer, and accounts for the
size of a Uint16Array element.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L98
Since: 4.0.0
bytesPerInstance
bytesPerInstance: number
Description:
The number of bytes per instance, used to determine how much of the vertex buffer to upload.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L200
Since: 4.0.0
currentBatchEntry
currentBatchEntry: Phaser.Types.Renderer.WebGL.WebGLBatchEntry
Description:
The current batch entry being filled with textures.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L218
Since: 4.0.0
floatsPerInstance
floatsPerInstance: number
Description:
The number of floats per instance, used to determine how much of the vertex buffer to update.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L209
Since: 4.0.0
indexBuffer
indexBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper
Description:
The index buffer defining vertex order.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L132
Since: 4.0.0
indicesPerInstance
indicesPerInstance: number
Description:
The number of indices per instance.
This is usually 6 for a quad.
Each index corresponds to a vertex in the vertex buffer.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L86
Since: 4.0.0
instanceCount
instanceCount: number
Description:
The number of instances currently in the batch.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L247
Since: 4.0.0
instancesPerBatch
instancesPerBatch: number
Description:
The number of instances per batch, used to determine the size of the
vertex buffer, and the number of instances to render.
This is usually limited by the maximum number of vertices that can be
distinguished with a 16-bit UNSIGNED_INT index buffer,
which is 65536. This is set in the game render config as batchSize.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L52
Since: 4.0.0
maxTexturesPerBatch
maxTexturesPerBatch: number
Description:
The maximum number of textures per batch entry.
This is usually set to the maximum number of texture units available,
but it might be smaller for some uses.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L110
Since: 4.0.0
programManager
programManager: Phaser.Renderer.WebGL.ProgramManager
Description:
The program manager used to create and manage shader programs.
This contains shader variants.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L164
Since: 4.0.0
vertexBufferLayout
vertexBufferLayout: Phaser.Renderer.WebGL.Wrappers.WebGLVertexBufferLayoutWrapper
Description:
The layout, data, and vertex buffer used to store the vertex data.
The default layout is for a quad with position, texture coordinate,
texture ID, tint effect, and tint color on each vertex.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L148
Since: 4.0.0
verticesPerInstance
verticesPerInstance: number
Description:
The number of vertices per instance.
This is usually 4 for a quad.
Each vertex corresponds to an index in the element buffer.
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L66
Since: 4.0.0
Inherited Methods
From Phaser.Renderer.WebGL.RenderNodes.RenderNode:
Public Methods
batch
<instance> batch([args])
Description:
Add an instance to the batch. Game objects call this method to add
themselves to the batch. This method should be overridden by subclasses.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| args | * | Yes | Arguments to pass to the batch handler. These will vary depending on the handler. |
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L407
Since: 4.0.0
resize
<instance> resize(width, height)
Description:
Set new dimensions for the renderer.
This should be overridden by subclasses.
This is called automatically when the renderer is resized.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| width | number | No | The new width of the renderer. |
| height | number | No | The new height of the renderer. |
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L365
Since: 4.0.0
run
<instance> run(drawingContext, [args])
Description:
Draw then empty the current batch.
This method is called automatically, by either this node or the manager,
when the batch is full, or when something else needs to be rendered.
This method should be overridden by subclasses.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| drawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The current drawing context. |
| args | * | Yes | Additional arguments to pass to the batch handler. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.RenderNode#run
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L392
Since: 4.0.0
updateTextureCount
<instance> updateTextureCount([count])
Description:
Update the number of draw calls per batch.
This should be overridden by subclasses.
This is called automatically by a listener
for the Phaser.Renderer.Events.SET_PARALLEL_TEXTURE_UNITS event,
triggered by the RenderNodeManager.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| count | number | Yes | The new number of draw calls per batch. If undefined, the maximum number of texture units is used. |
Source: src/renderer/webgl/renderNodes/BatchHandler.js#L378
Since: 4.0.0