Phaser API Documentation

  Version: 
Filter

The Single Pipeline is a special version of the Multi Pipeline that only ever uses one texture, bound to texture unit zero. Although not as efficient as the Multi Pipeline, it provides an easier way to create custom pipelines that only require a single bound texture.

Prior to Phaser v3.50 this pipeline didn't exist, but could be compared to the old TextureTintPipeline.

The fragment shader it uses can be found in shaders/src/Single.frag. The vertex shader it uses can be found in shaders/src/Single.vert.

The default shader attributes for this pipeline are:

inPosition (vec2, offset 0) inTexCoord (vec2, offset 8) inTexId (float, offset 16) - this value is always zero in the Single Pipeline inTintEffect (float, offset 20) inTint (vec4, offset 24, normalized)

The default shader uniforms for this pipeline are:

uProjectionMatrix (mat4) uResolution (vec2) uMainSampler (sampler2D, or sampler2D array)

Constructor:

new SinglePipeline(config)

Parameters:

name type description
config Phaser.Types.Renderer.WebGL.WebGLPipelineConfig

The configuration options for this pipeline.

Since: 3.50.0

Extends


Members

Description:

A temporary Transform Matrix, re-used internally during batching.

Type:
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix1
Since: 3.11.0
Focus
Focus

Description:

A temporary Transform Matrix, re-used internally during batching.

Type:
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix2
Since: 3.11.0
Focus
Focus

Description:

A temporary Transform Matrix, re-used internally during batching.

Type:
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix3
Since: 3.11.0
Focus
Focus
active: boolean
Focus
Focus

Description:

Indicates if the current pipeline is active, or not.

Toggle this property to enable or disable a pipeline from rendering anything.

Type:
boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#active
Since: 3.10.0
Focus
Focus

Description:

The currently active WebGLTextures, used as part of the batch process.

Reset to empty as part of the bind method.

Treat this array as read-only.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#activeTextures
Since: 3.60.0
Focus
Focus

Description:

The temporary Pipeline batch. This array contains the batch entries for the current frame, which is a package of textures and vertex offsets used for drawing. This package is built dynamically as the frame is built and cleared during the flush method.

Treat this array and all of its contents as read-only.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#batch
Since: 3.60.0
Focus
Focus
bytes: Uint8Array
Focus
Focus

Description:

Uint8 view to the vertexData ArrayBuffer. Used for uploading vertex buffer resources to the GPU.

Type:
Uint8Array
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#bytes
Since: 3.0.0
Focus
Focus

Description:

A temporary Transform Matrix, re-used internally during batching by the Shape Game Objects.

Type:
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#calcMatrix
Since: 3.55.0
Focus
Focus

Description:

The configuration object that was used to create this pipeline.

Treat this object as 'read only', because changing it post-creation will not impact this pipeline in any way. However, it is used internally for cloning and post-boot set-up.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#config
Since: 3.50.0
Focus
Focus

Description:

The most recently created Pipeline batch entry.

Reset to null as part of the flush method.

Treat this value as read-only.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#currentBatch
Since: 3.60.0
Focus
Focus
<private> currentFrame: Phaser.Textures.Frame
Focus
Focus

Description:

Internal texture frame reference.

Type:
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#currentFrame
Since: 3.55.0
Focus
Focus
currentRenderTarget: Phaser.Renderer.WebGL.RenderTarget
Focus
Focus

Description:

A reference to the currently bound Render Target instance from the WebGLPipeline.renderTargets array.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#currentRenderTarget
Since: 3.50.0
Focus
Focus

Description:

A reference to the currently bound WebGLShader instance from the WebGLPipeline.shaders array.

For lots of pipelines, this is the only shader, so it is a quick way to reference it without an array look-up.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#currentShader
Since: 3.50.0
Focus
Focus

Description:

The most recently bound texture, used as part of the batch process.

Reset to null as part of the flush method.

Treat this value as read-only.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#currentTexture
Since: 3.60.0
Focus
Focus
currentUnit: number
Focus
Focus

Description:

Holds the most recently assigned texture unit.

Treat this value as read-only.

Type:
number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#currentUnit
Since: 3.50.0
Focus
Focus
<private> fillTint: object
Focus
Focus

Description:

Cached fill tint.

Type:
object
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#fillTint
Since: 3.55.0
Focus
Focus
<private> firstQuad: Array.<number>
Focus
Focus

Description:

Internal path quad cache.

Type:
Array.<number>
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#firstQuad
Since: 3.55.0
Focus
Focus
forceZero: boolean
Focus
Focus

Description:

Some pipelines require the forced use of texture zero (like the light pipeline).

This property should be set when that is the case.

Type:
boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#forceZero
Since: 3.50.0
Focus
Focus
game: Phaser.Game
Focus
Focus

Description:

The Phaser Game instance to which this pipeline is bound.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#game
Since: 3.0.0
Focus
Focus
gl: WebGLRenderingContext
Focus
Focus

Description:

The WebGL context this WebGL Pipeline uses.

Type:
WebGLRenderingContext
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#gl
Since: 3.0.0
Focus
Focus
glReset: boolean
Focus
Focus

Description:

Has the GL Context been reset to the Phaser defaults since the last time this pipeline was bound? This is set automatically when the Pipeline Manager resets itself, usually after handing off to a 3rd party renderer like Spine.

You should treat this property as read-only.

Type:
boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#glReset
Since: 3.53.0
Focus
Focus
<readonly> hasBooted: boolean
Focus
Focus

Description:

Indicates if this pipeline has booted or not.

A pipeline boots only when the Game instance itself, and all associated systems, is fully ready.

Type:
boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#hasBooted
Since: 3.50.0
Focus
Focus
height: number
Focus
Focus

Description:

Height of the current viewport.

Type:
number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#height
Since: 3.0.0
Focus
Focus
<readonly> isPostFX: boolean
Focus
Focus

Description:

Indicates if this is a Post FX Pipeline, or not.

Type:
boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#isPostFX
Since: 3.50.0
Focus
Focus
<readonly> isPreFX: boolean
Focus
Focus

Description:

Indicates if this is a Pre FX Pipeline, or not.

Type:
boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#isPreFX
Since: 3.60.0
Focus
Focus

Description:

A reference to the WebGL Pipeline Manager.

This is initially undefined and only set when this pipeline is added to the manager.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#manager
Since: 3.50.0
Focus
Focus
name: string
Focus
Focus

Description:

Name of the pipeline. Used for identification and setting from Game Objects.

Type:
string
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#name
Since: 3.0.0
Focus
Focus
<private> polygonCache: array
Focus
Focus

Description:

Used internally for triangulating a polygon.

Type:
array
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#polygonCache
Since: 3.55.0
Focus
Focus
<private> prevQuad: Array.<number>
Focus
Focus

Description:

Internal path quad cache.

Type:
Array.<number>
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#prevQuad
Since: 3.55.0
Focus
Focus
projectionHeight: number
Focus
Focus

Description:

The cached height of the Projection matrix.

Type:
number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#projectionHeight
Since: 3.50.0
Focus
Focus
projectionMatrix: Phaser.Math.Matrix4
Focus
Focus

Description:

The Projection matrix, used by shaders as 'uProjectionMatrix' uniform.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#projectionMatrix
Since: 3.50.0
Focus
Focus
projectionWidth: number
Focus
Focus

Description:

The cached width of the Projection matrix.

Type:
number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#projectionWidth
Since: 3.50.0
Focus
Focus
renderTargets: Array.<Phaser.Renderer.WebGL.RenderTarget>
Focus
Focus

Description:

An array of RenderTarget instances that belong to this pipeline.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#renderTargets
Since: 3.50.0
Focus
Focus

Description:

The WebGL Renderer instance to which this pipeline is bound.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#renderer
Since: 3.0.0
Focus
Focus
resizeUniform: string
Focus
Focus

Description:

If the WebGL Renderer changes size, this uniform will be set with the new width and height values as part of the pipeline resize method. Various built-in pipelines, such as the MultiPipeline, set this property automatically to uResolution.

Type:
string
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#resizeUniform
Since: 3.80.0
Focus
Focus

Description:

An array of all the WebGLShader instances that belong to this pipeline.

Shaders manage their own attributes and uniforms, but share the same vertex data buffer, which belongs to this pipeline.

Shaders are set in a call to the setShadersFromConfig method, which happens automatically, but can also be called at any point in your game. See the method documentation for details.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#shaders
Since: 3.50.0
Focus
Focus
<private> strokeTint: object
Focus
Focus

Description:

Cached stroke tint.

Type:
object
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#strokeTint
Since: 3.55.0
Focus
Focus
<private> tempTriangle: array
Focus
Focus

Description:

Used internally to draw stroked triangles.

Type:
array
Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#tempTriangle
Since: 3.55.0
Focus
Focus
topology: GLenum
Focus
Focus

Description:

The primitive topology which the pipeline will use to submit draw calls.

Defaults to GL_TRIANGLES if not otherwise set in the config.

Type:
GLenum
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#topology
Since: 3.0.0
Focus
Focus

Description:

The WebGLBuffer that holds the vertex data.

Created from the vertexData ArrayBuffer. If vertices are set in the config, a STATIC_DRAW buffer is created. If not, a DYNAMIC_DRAW buffer is created.

Type:
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer
Since: 3.0.0
Focus
Focus
vertexCapacity: number
Focus
Focus

Description:

The total number of vertices that this pipeline batch can hold before it will flush.

This defaults to renderer batchSize * 6, where batchSize is defined in the Renderer Game Config.

Type:
number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity
Since: 3.0.0
Focus
Focus
vertexCount: number
Focus
Focus

Description:

The current number of vertices that have been added to the pipeline batch.

Type:
number
Default: 0
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#vertexCount
Since: 3.0.0
Focus
Focus
<readonly> vertexData: ArrayBuffer
Focus
Focus

Description:

Raw byte buffer of vertices.

Either set via the config object vertices property, or generates a new Array Buffer of size vertexCapacity * vertexSize.

Type:
ArrayBuffer
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#vertexData
Since: 3.0.0
Focus
Focus
vertexViewF32: Float32Array
Focus
Focus

Description:

Float32 view of the array buffer containing the pipeline's vertices.

Type:
Float32Array
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#vertexViewF32
Since: 3.0.0
Focus
Focus
vertexViewU32: Uint32Array
Focus
Focus

Description:

Uint32 view of the array buffer containing the pipeline's vertices.

Type:
Uint32Array
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#vertexViewU32
Since: 3.0.0
Focus
Focus
view: HTMLCanvasElement
Focus
Focus

Description:

The canvas which this WebGL Pipeline renders to.

Type:
HTMLCanvasElement
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#view
Since: 3.0.0
Focus
Focus
width: number
Focus
Focus

Description:

Width of the current viewport.

Type:
number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#width
Since: 3.0.0
Focus
Focus

Methods

addListener(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#addListener
Since: 3.0.0
Focus
Focus
addTextureToBatch(texture)
Focus
Focus

Description:

Adds the given texture to the current WebGL Pipeline Batch Entry and increases the batch entry unit and maxUnit values by 1.

Parameters:

name type description
texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper

The texture assigned to this batch entry.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#addTextureToBatch
Since: 3.60.0
Focus
Focus
batchFillPath(path, currentMatrix, parentMatrix)
Focus
Focus

Description:

Adds the given path to the vertex batch for rendering.

It works by taking the array of path data and then passing it through Earcut, which creates a list of polygons. Each polygon is then added to the batch.

The path is always automatically closed because it's filled.

Parameters:

name type description
path Array.<Phaser.Types.Math.Vector2Like>

Collection of points that represent the path.

currentMatrix Phaser.GameObjects.Components.TransformMatrix

The current transform.

parentMatrix Phaser.GameObjects.Components.TransformMatrix

The parent transform.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillPath
Since: 3.55.0
Focus
Focus
batchFillRect(x, y, width, height, currentMatrix, parentMatrix)
Focus
Focus

Description:

Pushes a filled rectangle into the vertex batch.

Rectangle factors in the given transform matrices before adding to the batch.

Parameters:

name type description
x number

Horizontal top left coordinate of the rectangle.

y number

Vertical top left coordinate of the rectangle.

width number

Width of the rectangle.

height number

Height of the rectangle.

currentMatrix Phaser.GameObjects.Components.TransformMatrix

The current transform.

parentMatrix Phaser.GameObjects.Components.TransformMatrix

The parent transform.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillRect
Since: 3.55.0
Focus
Focus
batchFillTriangle(x0, y0, x1, y1, x2, y2, currentMatrix, parentMatrix)
Focus
Focus

Description:

Pushes a filled triangle into the vertex batch.

Triangle factors in the given transform matrices before adding to the batch.

Parameters:

name type description
x0 number

Point 0 x coordinate.

y0 number

Point 0 y coordinate.

x1 number

Point 1 x coordinate.

y1 number

Point 1 y coordinate.

x2 number

Point 2 x coordinate.

y2 number

Point 2 y coordinate.

currentMatrix Phaser.GameObjects.Components.TransformMatrix

The current transform.

parentMatrix Phaser.GameObjects.Components.TransformMatrix

The parent transform.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillTriangle
Since: 3.55.0
Focus
Focus
batchLine(ax, ay, bx, by, aLineWidth, bLineWidth, index, closePath, currentMatrix, parentMatrix)
Focus
Focus

Description:

Creates a line out of 4 quads and adds it to the vertex batch based on the given line values.

Parameters:

name type description
ax number

x coordinate of the start of the line.

ay number

y coordinate of the start of the line.

bx number

x coordinate of the end of the line.

by number

y coordinate of the end of the line.

aLineWidth number

Width of the start of the line.

bLineWidth number

Width of the end of the line.

index number

If this line is part of a multi-line draw, the index of the line in the draw.

closePath boolean

Does this line close a multi-line path?

currentMatrix Phaser.GameObjects.Components.TransformMatrix

The current transform.

parentMatrix Phaser.GameObjects.Components.TransformMatrix

The parent transform.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchLine
Since: 3.55.0
Focus
Focus
batchQuad(gameObject, x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, [texture], [unit])
Focus
Focus

Description:

Adds the vertices data into the batch and flushes if full.

Assumes 6 vertices in the following arrangement:

0----3
|\  B|
| \  |
|  \ |
| A \|
|    \
1----2

Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3

Parameters:

name type arguments description
gameObject null | Phaser.GameObjects.GameObject

The Game Object, if any, drawing this quad.

x0 number

The top-left x position.

y0 number

The top-left y position.

x1 number

The bottom-left x position.

y1 number

The bottom-left y position.

x2 number

The bottom-right x position.

y2 number

The bottom-right y position.

x3 number

The top-right x position.

y3 number

The top-right y position.

u0 number

UV u0 value.

v0 number

UV v0 value.

u1 number

UV u1 value.

v1 number

UV v1 value.

tintTL number

The top-left tint color value.

tintTR number

The top-right tint color value.

tintBL number

The bottom-left tint color value.

tintBR number

The bottom-right tint color value.

tintEffect number | boolean

The tint effect for the shader to use.

texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper <optional>

Texture that will be assigned to the current batch if a flush occurs.

unit number <optional>

Texture unit to which the texture needs to be bound.

Returns:
Description:

true if this method caused the batch to flush, otherwise false.

Type:
  • boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#batchQuad
Since: 3.50.0
Focus
Focus
batchSprite(gameObject, camera, [parentTransformMatrix])
Focus
Focus

Description:

Takes a Sprite Game Object, or any object that extends it, and adds it to the batch.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.Image | Phaser.GameObjects.Sprite

The texture based Game Object to add to the batch.

camera Phaser.Cameras.Scene2D.Camera

The Camera to use for the rendering transform.

parentTransformMatrix Phaser.GameObjects.Components.TransformMatrix <optional>

The transform matrix of the parent container, if set.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchSprite
Focus
Focus
batchStrokePath(path, lineWidth, pathOpen, currentMatrix, parentMatrix)
Focus
Focus

Description:

Adds the given path to the vertex batch for rendering.

It works by taking the array of path data and calling batchLine for each section of the path.

The path is optionally closed at the end.

Parameters:

name type description
path Array.<Phaser.Types.Math.Vector2Like>

Collection of points that represent the path.

lineWidth number

The width of the line segments in pixels.

pathOpen boolean

Indicates if the path should be closed or left open.

currentMatrix Phaser.GameObjects.Components.TransformMatrix

The current transform.

parentMatrix Phaser.GameObjects.Components.TransformMatrix

The parent transform.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchStrokePath
Since: 3.55.0
Focus
Focus
batchStrokeTriangle(x0, y0, x1, y1, x2, y2, lineWidth, currentMatrix, parentMatrix)
Focus
Focus

Description:

Pushes a stroked triangle into the vertex batch.

Triangle factors in the given transform matrices before adding to the batch.

The triangle is created from 3 lines and drawn using the batchStrokePath method.

Parameters:

name type description
x0 number

Point 0 x coordinate.

y0 number

Point 0 y coordinate.

x1 number

Point 1 x coordinate.

y1 number

Point 1 y coordinate.

x2 number

Point 2 x coordinate.

y2 number

Point 2 y coordinate.

lineWidth number

The width of the line in pixels.

currentMatrix Phaser.GameObjects.Components.TransformMatrix

The current transform.

parentMatrix Phaser.GameObjects.Components.TransformMatrix

The parent transform.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchStrokeTriangle
Since: 3.55.0
Focus
Focus
batchTexture(gameObject, texture, textureWidth, textureHeight, srcX, srcY, srcWidth, srcHeight, scaleX, scaleY, rotation, flipX, flipY, scrollFactorX, scrollFactorY, displayOriginX, displayOriginY, frameX, frameY, frameWidth, frameHeight, tintTL, tintTR, tintBL, tintBR, tintEffect, uOffset, vOffset, camera, parentTransformMatrix, [skipFlip], [textureUnit], [skipPrePost])
Focus
Focus

Description:

Generic function for batching a textured quad using argument values instead of a Game Object.

Parameters:

name type arguments Default description
gameObject Phaser.GameObjects.GameObject

Source GameObject.

texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper

Texture associated with the quad.

textureWidth number

Real texture width.

textureHeight number

Real texture height.

srcX number

X coordinate of the quad.

srcY number

Y coordinate of the quad.

srcWidth number

Width of the quad.

srcHeight number

Height of the quad.

scaleX number

X component of scale.

scaleY number

Y component of scale.

rotation number

Rotation of the quad.

flipX boolean

Indicates if the quad is horizontally flipped.

flipY boolean

Indicates if the quad is vertically flipped.

scrollFactorX number

By which factor is the quad affected by the camera horizontal scroll.

scrollFactorY number

By which factor is the quad effected by the camera vertical scroll.

displayOriginX number

Horizontal origin in pixels.

displayOriginY number

Vertical origin in pixels.

frameX number

X coordinate of the texture frame.

frameY number

Y coordinate of the texture frame.

frameWidth number

Width of the texture frame.

frameHeight number

Height of the texture frame.

tintTL number

Tint for top left.

tintTR number

Tint for top right.

tintBL number

Tint for bottom left.

tintBR number

Tint for bottom right.

tintEffect number

The tint effect.

uOffset number

Horizontal offset on texture coordinate.

vOffset number

Vertical offset on texture coordinate.

camera Phaser.Cameras.Scene2D.Camera

Current used camera.

parentTransformMatrix Phaser.GameObjects.Components.TransformMatrix

Parent container.

skipFlip boolean <optional> false

Skip the renderTexture check.

textureUnit number <optional>

The texture unit to set (defaults to currently bound if undefined or null)

skipPrePost boolean <optional> false

Skip the pre and post manager calls?

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchTexture
Focus
Focus
batchTextureFrame(frame, x, y, tint, alpha, transformMatrix, [parentTransformMatrix])
Focus
Focus

Description:

Adds a Texture Frame into the batch for rendering.

Parameters:

name type arguments description
frame Phaser.Textures.Frame

The Texture Frame to be rendered.

x number

The horizontal position to render the texture at.

y number

The vertical position to render the texture at.

tint number

The tint color.

alpha number

The alpha value.

transformMatrix Phaser.GameObjects.Components.TransformMatrix

The Transform Matrix to use for the texture.

parentTransformMatrix Phaser.GameObjects.Components.TransformMatrix <optional>

A parent Transform Matrix.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchTextureFrame
Since: 3.12.0
Focus
Focus
batchTri(gameObject, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect, [texture], [unit])
Focus
Focus

Description:

Adds the vertices data into the batch and flushes if full.

Assumes 3 vertices in the following arrangement:

0
|\
| \
|  \
|   \
|    \
1-----2

Parameters:

name type arguments description
gameObject null | Phaser.GameObjects.GameObject

The Game Object, if any, drawing this quad.

x1 number

The bottom-left x position.

y1 number

The bottom-left y position.

x2 number

The bottom-right x position.

y2 number

The bottom-right y position.

x3 number

The top-right x position.

y3 number

The top-right y position.

u0 number

UV u0 value.

v0 number

UV v0 value.

u1 number

UV u1 value.

v1 number

UV v1 value.

tintTL number

The top-left tint color value.

tintTR number

The top-right tint color value.

tintBL number

The bottom-left tint color value.

tintEffect number | boolean

The tint effect for the shader to use.

texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper <optional>

Texture that will be assigned to the current batch if a flush occurs.

unit number <optional>

Texture unit to which the texture needs to be bound.

Returns:
Description:

true if this method caused the batch to flush, otherwise false.

Type:
  • boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#batchTri
Since: 3.50.0
Focus
Focus
batchVert(x, y, u, v, unit, tintEffect, tint)
Focus
Focus

Description:

Adds a single vertex to the current vertex buffer and increments the vertexCount property by 1.

This method is called directly by batchTri and batchQuad.

It does not perform any batch limit checking itself, so if you need to call this method directly, do so in the same way that batchQuad does, for example.

Parameters:

name type description
x number

The vertex x position.

y number

The vertex y position.

u number

UV u value.

v number

UV v value.

unit number

Texture unit to which the texture needs to be bound.

tintEffect number | boolean

The tint effect for the shader to use.

tint number

The tint color value.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#batchVert
Since: 3.50.0
Focus
Focus
bind([currentShader])
Focus
Focus

Description:

This method is called every time the Pipeline Manager makes this pipeline the currently active one.

It binds the resources and shader needed for this pipeline, including setting the vertex buffer and attribute pointers.

Parameters:

name type arguments description
currentShader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set as being current.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#bind
Since: 3.0.0
Focus
Focus
bindRenderTarget([target], [unit])
Focus
Focus

Description:

Activates the given Render Target texture and binds it to the requested WebGL texture slot.

Parameters:

name type arguments description
target Phaser.Renderer.WebGL.RenderTarget <optional>

The Render Target to activate and bind.

unit number <optional>

The WebGL texture ID to activate. Defaults to gl.TEXTURE0.

Returns:
Description:

This WebGL Pipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#bindRenderTarget
Since: 3.50.0
Focus
Focus
bindTexture([target], [unit])
Focus
Focus

Description:

Activates the given WebGL Texture and binds it to the requested texture slot.

Parameters:

name type arguments description
target Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper <optional>

Texture to activate and bind.

unit number <optional>

The WebGL texture ID to activate. Defaults to gl.TEXTURE0.

Returns:
Description:

This WebGL Pipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#bindTexture
Since: 3.50.0
Focus
Focus
boot()
Focus
Focus

Description:

Called every time the pipeline is bound by the renderer. Sets the shader program, vertex buffer and other resources. Should only be called when changing pipeline.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#boot
Since: 3.50.0
Focus
Focus
createBatch(texture)
Focus
Focus

Description:

Creates a new WebGL Pipeline Batch Entry, sets the texture unit as zero and pushes the entry into the batch.

Parameters:

name type description
texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper

The texture assigned to this batch entry.

Returns:
Description:

The texture unit that was bound.

Type:
  • number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#createBatch
Since: 3.60.0
Focus
Focus
destroy()
Focus
Focus

Description:

Destroys all shader instances, removes all object references and nulls all external references.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#destroy
Focus
Focus
drawFillRect(x, y, width, height, color, alpha, [texture], [flipUV])
Focus
Focus

Description:

Pushes a filled rectangle into the vertex batch.

The dimensions are run through Math.floor before the quad is generated.

Rectangle has no transform values and isn't transformed into the local space.

Used for directly batching untransformed rectangles, such as Camera background colors.

Parameters:

name type arguments Default description
x number

Horizontal top left coordinate of the rectangle.

y number

Vertical top left coordinate of the rectangle.

width number

Width of the rectangle.

height number

Height of the rectangle.

color number

Color of the rectangle to draw.

alpha number

Alpha value of the rectangle to draw.

texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper <optional>

texture that will be assigned to the current batch if a flush occurs.

flipUV boolean <optional> true

Flip the vertical UV coordinates of the texture before rendering?

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#drawFillRect
Since: 3.50.0
Focus
Focus
emit(event, [args])
Focus
Focus

Description:

Calls each of the listeners registered for a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

args * <optional>

Additional arguments that will be passed to the event handler.

Returns:
Description:

true if the event had listeners, else false.

Type:
  • boolean
Inherited from: Phaser.Events.EventEmitter#emit
Since: 3.0.0
Focus
Focus
eventNames()
Focus
Focus

Description:

Return an array listing the events for which the emitter has registered listeners.

Type:
  • Array.<(string
  • symbol)>
Inherited from: Phaser.Events.EventEmitter#eventNames
Since: 3.0.0
Focus
Focus
flipProjectionMatrix([flipY])
Focus
Focus

Description:

Adjusts this pipelines ortho Projection Matrix to flip the y and bottom values. Call with 'false' as the parameter to flip them back again.

Parameters:

name type arguments Default description
flipY boolean <optional> true

Flip the y and bottom values?

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#flipProjectionMatrix
Since: 3.60.0
Focus
Focus
flush([isPostFlush])
Focus
Focus

Description:

Uploads the vertex data and emits a draw call for the current batch of vertices.

Parameters:

name type arguments Default description
isPostFlush boolean <optional> false

Was this flush invoked as part of a post-process, or not?

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#flush
Since: 3.0.0
Focus
Focus
getShaderByName(name)
Focus
Focus

Description:

Searches all shaders in this pipeline for one matching the given name, then returns it.

Parameters:

name type description
name string

The index of the shader to set.

Returns:
Description:

The WebGLShader instance, if found.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#getShaderByName
Since: 3.50.0
Focus
Focus
listenerCount(event)
Focus
Focus

Description:

Return the number of listeners listening to a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The number of listeners.

Type:
  • number
Inherited from: Phaser.Events.EventEmitter#listenerCount
Since: 3.0.0
Focus
Focus
listeners(event)
Focus
Focus

Description:

Return the listeners registered for a given event.

Parameters:

name type description
event string | symbol

The event name.

Returns:
Description:

The registered listeners.

Type:
  • Array.<function()>
Inherited from: Phaser.Events.EventEmitter#listeners
Since: 3.0.0
Focus
Focus
off(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#off
Since: 3.0.0
Focus
Focus
on(event, fn, [context])
Focus
Focus

Description:

Add a listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#on
Since: 3.0.0
Focus
Focus
onActive(currentShader)
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called every time the Pipeline Manager makes this the active pipeline. It is called at the end of the WebGLPipeline.bind method, after the current shader has been set. The current shader is passed to this hook.

For example, if a display list has 3 Sprites in it that all use the same pipeline, this hook will only be called for the first one, as the 2nd and 3rd Sprites do not cause the pipeline to be changed.

If you need to listen for that event instead, use the onBind hook.

Parameters:

name type description
currentShader Phaser.Renderer.WebGL.WebGLShader

The shader that was set as current.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onActive
Since: 3.50.0
Focus
Focus
onAfterFlush([isPostFlush])
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called immediately after this pipeline has finished flushing its batch.

It is called after the gl.drawArrays call.

You can perform additional post-render effects, but be careful not to call flush on this pipeline from within this method, or you'll cause an infinite loop.

To apply changes pre-render, see onBeforeFlush.

Parameters:

name type arguments Default description
isPostFlush boolean <optional> false

Was this flush invoked as part of a post-process, or not?

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onAfterFlush
Since: 3.50.0
Focus
Focus
onBatch([gameObject])
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called every time the batchQuad or batchTri methods are called. If this was as a result of a Game Object, then the Game Object reference is passed to this hook too.

This hook is called after the quad (or tri) has been added to the batch, so you can safely call 'flush' from within this.

Note that Game Objects may call batchQuad or batchTri multiple times for a single draw, for example the Graphics Game Object.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject <optional>

The Game Object that invoked this pipeline, if any.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onBatch
Since: 3.50.0
Focus
Focus
onBeforeFlush([isPostFlush])
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called every time this pipeline is asked to flush its batch.

It is called immediately before the gl.bufferData and gl.drawArrays calls are made, so you can perform any final pre-render modifications. To apply changes post-render, see onAfterFlush.

Parameters:

name type arguments Default description
isPostFlush boolean <optional> false

Was this flush invoked as part of a post-process, or not?

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onBeforeFlush
Since: 3.50.0
Focus
Focus
onBind([gameObject])
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called every time a Game Object asks the Pipeline Manager to use this pipeline, even if the pipeline is already active.

Unlike the onActive method, which is only called when the Pipeline Manager makes this pipeline active, this hook is called for every Game Object that requests use of this pipeline, allowing you to perform per-object set-up, such as loading shader uniform data.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject <optional>

The Game Object that invoked this pipeline, if any.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onBind
Since: 3.50.0
Focus
Focus
onBoot()
Focus
Focus

Description:

This method is called once when this pipeline has finished being set-up at the end of the boot process. By the time this method is called, all of the shaders are ready and configured.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onBoot
Since: 3.50.0
Focus
Focus
onDraw(renderTarget, [swapTarget])
Focus
Focus

Description:

This method is only used by Sprite FX and Post FX Pipelines and those that extend from them.

This method is called every time the postBatch method is called and is passed a reference to the current render target.

At the very least a Post FX Pipeline should call this.bindAndDraw(renderTarget), however, you can do as much additional processing as you like in this method if you override it from within your own pipelines.

Parameters:

name type arguments description
renderTarget Phaser.Renderer.WebGL.RenderTarget

The Render Target.

swapTarget Phaser.Renderer.WebGL.RenderTarget <optional>

A Swap Render Target, useful for double-buffer effects. Only set by SpriteFX Pipelines.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onDraw
Since: 3.50.0
Focus
Focus
onPostBatch([gameObject])
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called immediately after a Game Object has been added to the batch.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject <optional>

The Game Object that invoked this pipeline, if any.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onPostBatch
Since: 3.50.0
Focus
Focus
onPostRender()
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called once per frame, after all rendering has happened and snapshots have been taken.

It is called at the very end of the rendering process, once all Cameras, for all Scenes, have been rendered.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onPostRender
Since: 3.50.0
Focus
Focus
onPreBatch([gameObject])
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called immediately before a Game Object is about to add itself to the batch.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject <optional>

The Game Object that invoked this pipeline, if any.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onPreBatch
Since: 3.50.0
Focus
Focus
onPreRender()
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called once per frame, right before anything has been rendered, but after the canvas has been cleared. If this pipeline has a render target, it will also have been cleared by this point.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onPreRender
Since: 3.50.0
Focus
Focus
onRebind()
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called when the Pipeline Manager needs to rebind this pipeline. This happens after a pipeline has been cleared, usually when passing control over to a 3rd party WebGL library, like Spine, and then returing to Phaser again.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onRebind
Since: 3.50.0
Focus
Focus
onRender(scene, camera)
Focus
Focus

Description:

By default this is an empty method hook that you can override and use in your own custom pipelines.

This method is called once per frame, by every Camera in a Scene that wants to render.

It is called at the start of the rendering process, before anything has been drawn to the Camera.

Parameters:

name type description
scene Phaser.Scene

The Scene being rendered.

camera Phaser.Cameras.Scene2D.Camera

The Scene Camera being rendered with.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onRender
Since: 3.50.0
Focus
Focus
onResize(width, height)
Focus
Focus

Description:

This method is called once when this pipeline has finished being set-up at the end of the boot process. By the time this method is called, all of the shaders are ready and configured. It's also called if the renderer changes size.

Parameters:

name type description
width number

The new width of this WebGL Pipeline.

height number

The new height of this WebGL Pipeline.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#onResize
Since: 3.50.0
Focus
Focus
once(event, fn, [context])
Focus
Focus

Description:

Add a one-time listener for a given event.

Parameters:

name type arguments Default description
event string | symbol

The event name.

fn function

The listener function.

context * <optional> this

The context to invoke the listener with.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#once
Since: 3.0.0
Focus
Focus
postBatch([gameObject])
Focus
Focus

Description:

This method is called as a result of the WebGLPipeline.batchQuad method, right after a quad belonging to a Game Object has been added to the batch. When this is called, the renderer has just performed a flush.

It calls the onDraw hook followed by the onPostBatch hook, which can be used to perform additional Post FX Pipeline processing.

It is also called as part of the PipelineManager.postBatch method when processing Post FX Pipelines.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera <optional>

The Game Object or Camera that invoked this pipeline, if any.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#postBatch
Since: 3.50.0
Focus
Focus
preBatch([gameObject])
Focus
Focus

Description:

This method is called as a result of the WebGLPipeline.batchQuad method, right before a quad belonging to a Game Object is about to be added to the batch. When this is called, the renderer has just performed a flush. It will bind the current render target, if any are set and finally call the onPreBatch hook.

It is also called as part of the PipelineManager.preBatch method when processing Post FX Pipelines.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera <optional>

The Game Object or Camera that invoked this pipeline, if any.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#preBatch
Since: 3.50.0
Focus
Focus
pushBatch(texture)
Focus
Focus

Description:

Takes the given WebGLTextureWrapper and determines what to do with it.

If there is no current batch (i.e. after a flush) it will create a new batch from it.

If the texture is already bound, it will return the current texture unit.

If the texture already exists in the current batch, the unit gets reset to match it.

If the texture cannot be found in the current batch, and it supports multiple textures, it's added into the batch and the unit indexes are advanced.

Parameters:

name type description
texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper

The texture assigned to this batch entry.

Returns:
Description:

The texture unit that was bound.

Type:
  • number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#pushBatch
Since: 3.60.0
Focus
Focus
rebind([currentShader])
Focus
Focus

Description:

This method is called every time the Pipeline Manager rebinds this pipeline.

It resets all shaders this pipeline uses, setting their attributes again.

Parameters:

name type arguments description
currentShader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set as being current.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#rebind
Since: 3.0.0
Focus
Focus
removeAllListeners([event])
Focus
Focus

Description:

Remove all listeners, or those of the specified event.

Parameters:

name type arguments description
event string | symbol <optional>

The event name.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeAllListeners
Since: 3.0.0
Focus
Focus
removeListener(event, [fn], [context], [once])
Focus
Focus

Description:

Remove the listeners of a given event.

Parameters:

name type arguments description
event string | symbol

The event name.

fn function <optional>

Only remove the listeners that match this function.

context * <optional>

Only remove the listeners that have this context.

once boolean <optional>

Only remove one-time listeners.

Returns:
Description:

this.

Inherited from: Phaser.Events.EventEmitter#removeListener
Since: 3.0.0
Focus
Focus
resize(width, height)
Focus
Focus

Description:

Resizes the properties used to describe the viewport.

This method is called automatically by the renderer during its resize handler.

Parameters:

name type description
width number

The new width of this WebGL Pipeline.

height number

The new height of this WebGL Pipeline.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#resize
Since: 3.0.0
Focus
Focus
restoreContext()
Focus
Focus

Description:

This method is called if the WebGL context is lost and restored. It ensures that uniforms are synced back to the GPU for all shaders in this pipeline.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#restoreContext
Since: 3.80.0
Focus
Focus
set1f(name, x, [shader])
Focus
Focus

Description:

Sets a 1f uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

The new value of the float uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set1f
Since: 3.50.0
Focus
Focus
set1fv(name, arr, [shader])
Focus
Focus

Description:

Sets a 1fv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set1fv
Since: 3.50.0
Focus
Focus
set1i(name, x, [shader])
Focus
Focus

Description:

Sets a 1i uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

The new value of the int uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set1i
Since: 3.50.0
Focus
Focus
set1iv(name, arr, [shader])
Focus
Focus

Description:

Sets a 1iv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set1iv
Since: 3.50.0
Focus
Focus
set2f(name, x, y, [shader])
Focus
Focus

Description:

Sets a 2f uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

The new X component of the vec2 uniform.

y number

The new Y component of the vec2 uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set2f
Since: 3.50.0
Focus
Focus
set2fv(name, arr, [shader])
Focus
Focus

Description:

Sets a 2fv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set2fv
Since: 3.50.0
Focus
Focus
set2i(name, x, y, [shader])
Focus
Focus

Description:

Sets a 2i uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

The new X component of the ivec2 uniform.

y number

The new Y component of the ivec2 uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set2i
Since: 3.50.0
Focus
Focus
set2iv(name, arr, [shader])
Focus
Focus

Description:

Sets a 2iv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set2iv
Since: 3.50.0
Focus
Focus
set3f(name, x, y, z, [shader])
Focus
Focus

Description:

Sets a 3f uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

The new X component of the vec3 uniform.

y number

The new Y component of the vec3 uniform.

z number

The new Z component of the vec3 uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set3f
Since: 3.50.0
Focus
Focus
set3fv(name, arr, [shader])
Focus
Focus

Description:

Sets a 3fv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set3fv
Since: 3.50.0
Focus
Focus
set3i(name, x, y, z, [shader])
Focus
Focus

Description:

Sets a 3i uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

The new X component of the ivec3 uniform.

y number

The new Y component of the ivec3 uniform.

z number

The new Z component of the ivec3 uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set3i
Since: 3.50.0
Focus
Focus
set3iv(name, arr, [shader])
Focus
Focus

Description:

Sets a 3iv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set3iv
Since: 3.50.0
Focus
Focus
set4f(name, x, y, z, w, [shader])
Focus
Focus

Description:

Sets a 4f uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

X component of the uniform

y number

Y component of the uniform

z number

Z component of the uniform

w number

W component of the uniform

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set4f
Since: 3.50.0
Focus
Focus
set4fv(name, arr, [shader])
Focus
Focus

Description:

Sets a 4fv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set4fv
Since: 3.50.0
Focus
Focus
set4i(name, x, y, z, w, [shader])
Focus
Focus

Description:

Sets a 4i uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

x number

X component of the uniform.

y number

Y component of the uniform.

z number

Z component of the uniform.

w number

W component of the uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set4i
Since: 3.50.0
Focus
Focus
set4iv(name, arr, [shader])
Focus
Focus

Description:

Sets a 4iv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

arr Array.<number> | Float32Array

The new value to be used for the uniform variable.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#set4iv
Since: 3.50.0
Focus
Focus
setBoolean(name, value, [shader])
Focus
Focus

Description:

Sets a boolean uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

value boolean

The new value of the boolean uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setBoolean
Since: 3.60.0
Focus
Focus
setGameObject(gameObject, [frame])
Focus
Focus

Description:

Custom pipelines can use this method in order to perform any required pre-batch tasks for the given Game Object. It must return the texture unit the Game Object was assigned.

Parameters:

name type arguments description
gameObject Phaser.GameObjects.GameObject

The Game Object being rendered or added to the batch.

frame Phaser.Textures.Frame <optional>

Optional frame to use. Can override that of the Game Object.

Returns:
Description:

The texture unit the Game Object has been assigned.

Type:
  • number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setGameObject
Since: 3.50.0
Focus
Focus
setMatrix2fv(name, transpose, matrix, [shader])
Focus
Focus

Description:

Sets a matrix 2fv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

transpose boolean

Whether to transpose the matrix. Should be false.

matrix Array.<number> | Float32Array

The new values for the mat2 uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2fv
Since: 3.50.0
Focus
Focus
setMatrix3fv(name, transpose, matrix, [shader])
Focus
Focus

Description:

Sets a matrix 3fv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

transpose boolean

Whether to transpose the matrix. Should be false.

matrix Float32Array

The new values for the mat3 uniform.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3fv
Since: 3.50.0
Focus
Focus
setMatrix4fv(name, transpose, matrix, [shader])
Focus
Focus

Description:

Sets a matrix 4fv uniform value based on the given name on the currently set shader.

The current shader is bound, before the uniform is set, making it active within the WebGLRenderer. This means you can safely call this method from a location such as a Scene create or update method. However, when working within a Shader file directly, use the WebGLShader method equivalent instead, to avoid the program being set.

Parameters:

name type arguments description
name string

The name of the uniform to set.

transpose boolean

Whether to transpose the matrix. Should be false.

matrix Float32Array

The matrix data. If using a Matrix4 this should be the Matrix4.val property.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4fv
Since: 3.50.0
Focus
Focus
setProjectionMatrix(width, height)
Focus
Focus

Description:

Adjusts this pipelines ortho Projection Matrix to use the given dimensions and resets the uProjectionMatrix uniform on all bound shaders.

This method is called automatically by the renderer during its resize handler.

Parameters:

name type description
width number

The new width of this WebGL Pipeline.

height number

The new height of this WebGL Pipeline.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setProjectionMatrix
Since: 3.50.0
Focus
Focus
setShader(shader, [setAttributes], [vertexBuffer])
Focus
Focus

Description:

Sets the currently active shader within this pipeline.

Parameters:

name type arguments Default description
shader Phaser.Renderer.WebGL.WebGLShader

The shader to set as being current.

setAttributes boolean <optional> false

Should the vertex attribute pointers be set?

vertexBuffer Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper <optional>

The vertex buffer to be set before the shader is bound. Defaults to the one owned by this pipeline.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setShader
Since: 3.50.0
Focus
Focus
setShadersFromConfig(config)
Focus
Focus

Description:

Destroys all shaders currently set in the WebGLPipeline.shaders array and then parses the given config object, extracting the shaders from it, creating WebGLShader instances and finally setting them into the shaders array of this pipeline.

This is a destructive process. Be very careful when you call it, should you need to.

Parameters:

name type description
config Phaser.Types.Renderer.WebGL.WebGLPipelineConfig

The configuration object for this WebGL Pipeline.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setShadersFromConfig
Since: 3.50.0
Focus
Focus
setTexture2D([texture])
Focus
Focus

Description:

Sets the texture to be bound to the next available texture unit and returns the unit id.

Parameters:

name type arguments description
texture Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper <optional>

Texture that will be assigned to the current batch. If not given uses whiteTexture.

Returns:
Description:

The assigned texture unit.

Type:
  • number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setTexture2D
Since: 3.50.0
Focus
Focus
setTime(name, [shader])
Focus
Focus

Description:

Sets the current duration into a 1f uniform value based on the given name.

This can be used for mapping time uniform values, such as iTime.

Parameters:

name type arguments description
name string

The name of the uniform to set.

shader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set the value on. If not given, the currentShader is used.

Returns:
Description:

This WebGLPipeline instance.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setTime
Since: 3.50.0
Focus
Focus
setVertexBuffer([buffer])
Focus
Focus

Description:

Binds the vertex buffer to be the active ARRAY_BUFFER on the WebGL context.

It first checks to see if it's already set as the active buffer and only binds itself if not.

Parameters:

name type arguments description
buffer Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper <optional>

The Vertex Buffer to be bound. Defaults to the one owned by this pipeline.

Returns:
Description:

true if the vertex buffer was bound, or false if it was already bound.

Type:
  • boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#setVertexBuffer
Since: 3.50.0
Focus
Focus
shouldFlush([amount])
Focus
Focus

Description:

Check if the current batch of vertices is full.

You can optionally provide an amount parameter. If given, it will check if the batch needs to flush if the amount is added to it. This allows you to test if you should flush before populating the batch.

Parameters:

name type arguments description
amount number <optional>

Will the batch need to flush if this many vertices are added to it?

Returns:
Description:

true if the current batch should be flushed, otherwise false.

Type:
  • boolean
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush
Since: 3.0.0
Focus
Focus
shutdown()
Focus
Focus

Description:

Removes all listeners.

Inherited from: Phaser.Events.EventEmitter#shutdown
Since: 3.0.0
Focus
Focus
unbind()
Focus
Focus

Description:

This method is called every time the Pipeline Manager deactivates this pipeline, swapping from it to another one. This happens after a call to flush and before the new pipeline is bound.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#unbind
Since: 3.50.0
Focus
Focus
updateProjectionMatrix()
Focus
Focus

Description:

Adjusts this pipelines ortho Projection Matrix to match that of the global WebGL Renderer Projection Matrix.

This method is called automatically by the Pipeline Manager when this pipeline is set.

Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#updateProjectionMatrix
Since: 3.50.0
Focus
Focus
vertexAvailable()
Focus
Focus

Description:

Returns the number of vertices that can be added to the current batch before it will trigger a flush to happen.

Returns:
Description:

The number of vertices that can still be added to the current batch before it will flush.

Type:
  • number
Inherited from: Phaser.Renderer.WebGL.WebGLPipeline#vertexAvailable
Since: 3.60.0
Focus
Focus