BatchHandlerQuad
This RenderNode draws Standard Batch Render (SBR) quads in batches.
Constructor
new BatchHandlerQuad(manager, [config])
Parameters
| name | type | optional | description |
|---|---|---|---|
| manager | Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager | No | The manager that owns this RenderNode. |
| config | Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig | Yes | The configuration object for this handler. |
Scope: static
Extends
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L26
Since: 4.0.0
Inherited Members
From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:
- batchEntries
- bytesPerIndexPerInstance
- bytesPerInstance
- currentBatchEntry
- floatsPerInstance
- indexBuffer
- indicesPerInstance
- instanceCount
- instancesPerBatch
- maxTexturesPerBatch
- programManager
- vertexBufferLayout
- verticesPerInstance
From Phaser.Renderer.WebGL.RenderNodes.RenderNode:
Public Members
defaultConfig
defaultConfig: Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig
Description:
The default configuration object for this handler.
This is merged with the config object passed in the constructor.
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L101
Since: 4.0.0
nextRenderOptions
nextRenderOptions: object
Description:
The render options currently being built.
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L71
Since: 4.0.0
renderOptions
renderOptions: object
Description:
The current render options to which the batch is built.
These help define the shader.
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L44
Since: 4.0.0
Inherited Methods
From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:
From Phaser.Renderer.WebGL.RenderNodes.RenderNode:
Public Methods
batch
<instance> batch(currentContext, glTexture, x0, y0, x1, y1, x2, y2, x3, y3, texX, texY, texWidth, texHeight, tintFill, tintTL, tintBL, tintTR, tintBR, renderOptions, [args])
Description:
Add a quad to the batch.
For compatibility with TRIANGLE_STRIP rendering,
the vertices are added in the order:
-
Top-left
-
Bottom-left
-
Top-right
-
Bottom-right
Parameters:
| name | type | optional | description |
|---|---|---|---|
| currentContext | Phaser.Renderer.WebGL.DrawingContext | No | The current drawing context. |
| glTexture | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | No | The texture to render. |
| x0 | number | No | The x coordinate of the top-left corner. |
| y0 | number | No | The y coordinate of the top-left corner. |
| x1 | number | No | The x coordinate of the bottom-left corner. |
| y1 | number | No | The y coordinate of the bottom-left corner. |
| x2 | number | No | The x coordinate of the top-right corner. |
| y2 | number | No | The y coordinate of the top-right corner. |
| x3 | number | No | The x coordinate of the bottom-right corner. |
| y3 | number | No | The y coordinate of the bottom-right corner. |
| texX | number | No | The left u coordinate (0-1). |
| texY | number | No | The top v coordinate (0-1). |
| texWidth | number | No | The width of the texture (0-1). |
| texHeight | number | No | The height of the texture (0-1). |
| tintFill | boolean | No | Whether to tint the fill color. |
| tintTL | number | No | The top-left tint color. |
| tintBL | number | No | The bottom-left tint color. |
| tintTR | number | No | The top-right tint color. |
| tintBR | number | No | The bottom-right tint color. |
| renderOptions | Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerQuadRenderOptions | No | Optional render features. |
| args | * | Yes | Additional arguments for subclasses. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandler#batch
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L610
Since: 4.0.0
batchTextures
<instance> batchTextures(glTexture, renderOptions)
Description:
Process textures for batching.
This method is called automatically by the batch method.
It returns a piece of data used for various texture tasks,
depending on the render options.
The texture datum may be used for texture ID or normal map rotation.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| glTexture | Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper | No | The texture to render. |
| renderOptions | object | No | The current render options. |
Returns: number - The texture datum.
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L731
Since: 4.0.0
finalizeTextureCount
<instance> finalizeTextureCount(count)
Description:
Finalize the texture count for the current sub-batch.
This is called automatically when the render is run.
It requests a shader program with the necessary number of textures,
if that is less than the maximum allowed.
This reduces the number of textures the GPU must handle,
which can improve performance.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| count | number | No | The total number of textures in the batch. |
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L333
pushCurrentBatchEntry
<instance> pushCurrentBatchEntry()
Description:
Push the current batch entry to the batch entry list,
and create a new batch entry for future use.
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L819
Since: 4.0.0
run
<instance> run(drawingContext)
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.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| drawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The current drawing context. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandler#run
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L537
Since: 4.0.0
setupTextureUniforms
<instance> setupTextureUniforms(textures)
Description:
Update the texture uniforms for the current shader program.
This method is called automatically when the batch is run.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| textures | Array.<Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper> | No | The textures to render. |
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L295
Since: 4.0.0
setupUniforms
<instance> setupUniforms(drawingContext)
Description:
Update the uniforms for the current shader program.
This method is called automatically when the batch is run.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| drawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The current drawing context. |
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L253
Since: 4.0.0
updateRenderOptions
<instance> updateRenderOptions(renderOptions)
Description:
Update the render options for the current shader program.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| renderOptions | object | No | The new render options. |
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L375
Since: 4.0.0
updateShaderConfig
<instance> updateShaderConfig()
Description:
Update the shader configuration based on render options.
This is called automatically when the render options change.
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L434
Since: 4.0.0
updateTextureCount
<instance> updateTextureCount([count])
Description:
Update the number of draw calls per batch.
This rebuilds the shader program with the new draw call count.
The minimum number of draw calls is 1, and the maximum is the number of
texture units defined in the renderer.
Rebuilding the shader may be expensive, so use this sparingly.
If this runs during a batch, and the new count is less than the number of
textures in the current batch entry, the batch will be flushed before the
shader program is rebuilt, so none of the textures are skipped.
This is usually 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. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.BatchHandler#updateTextureCount
Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L190
Since: 4.0.0