Skip to main content
Version: Phaser v4.0.0-rc.6

BatchHandlerQuad

This RenderNode draws Standard Batch Render (SBR) quads in batches.

Constructor

new BatchHandlerQuad(manager, [config])

Parameters

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.
configPhaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfigYesThe configuration object for this handler.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.BatchHandler

Source: src/renderer/webgl/renderNodes/BatchHandlerQuad.js#L26
Since: 4.0.0

Inherited Members

From Phaser.Renderer.WebGL.RenderNodes.BatchHandler:

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:

nametypeoptionaldescription
currentContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.
glTexturePhaser.Renderer.WebGL.Wrappers.WebGLTextureWrapperNoThe texture to render.
x0numberNoThe x coordinate of the top-left corner.
y0numberNoThe y coordinate of the top-left corner.
x1numberNoThe x coordinate of the bottom-left corner.
y1numberNoThe y coordinate of the bottom-left corner.
x2numberNoThe x coordinate of the top-right corner.
y2numberNoThe y coordinate of the top-right corner.
x3numberNoThe x coordinate of the bottom-right corner.
y3numberNoThe y coordinate of the bottom-right corner.
texXnumberNoThe left u coordinate (0-1).
texYnumberNoThe top v coordinate (0-1).
texWidthnumberNoThe width of the texture (0-1).
texHeightnumberNoThe height of the texture (0-1).
tintFillbooleanNoWhether to tint the fill color.
tintTLnumberNoThe top-left tint color.
tintBLnumberNoThe bottom-left tint color.
tintTRnumberNoThe top-right tint color.
tintBRnumberNoThe bottom-right tint color.
renderOptionsPhaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerQuadRenderOptionsNoOptional render features.
args*YesAdditional 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:

nametypeoptionaldescription
glTexturePhaser.Renderer.WebGL.Wrappers.WebGLTextureWrapperNoThe texture to render.
renderOptionsobjectNoThe 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:

nametypeoptionaldescription
countnumberNoThe 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:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe 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:

nametypeoptionaldescription
texturesArray.<Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper>NoThe 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:

nametypeoptionaldescription
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe 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:

nametypeoptionaldescription
renderOptionsobjectNoThe 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:

nametypeoptionaldescription
countnumberYesThe 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