The WebGLPipeline
is a base class used by all of the core Phaser pipelines.
It describes the way elements will be rendered in WebGL. Internally, it handles compiling the shaders, creating vertex buffers, assigning primitive topology and binding vertex attributes, all based on the given configuration data.
The pipeline is configured by passing in a WebGLPipelineConfig
object. Please
see the documentation for this type to fully understand the configuration options
available to you.
Usually, you would not extend from this class directly, but would instead extend from one of the core pipelines, such as the Multi Pipeline.
The pipeline flow per render-step is as follows:
new WebGLPipeline(config)
name | type | description |
---|---|---|
config | Phaser.Types.Renderer.WebGL.WebGLPipelineConfig |
The configuration object for this WebGL Pipeline. |
Indicates if the current pipeline is active, or not.
Toggle this property to enable or disable a pipeline from rendering anything.
Uint8 view to the vertexData
ArrayBuffer. Used for uploading vertex buffer resources to the GPU.
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.
A reference to the currently bound Render Target instance from the WebGLPipeline.renderTargets
array.
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.
Holds the most recently assigned texture unit.
Treat this value as read-only.
Some pipelines require the forced use of texture zero (like the light pipeline).
This property should be set when that is the case.
The Phaser Game instance to which this pipeline is bound.
The WebGL context this WebGL Pipeline uses.
Indicates if this pipeline has booted or not.
A pipeline boots only when the Game instance itself, and all associated systems, is fully ready.
Height of the current viewport.
Indicates if this is a Post FX Pipeline, or not.
A reference to the WebGL Pipeline Manager.
This is initially undefined and only set when this pipeline is added to the manager.
Name of the pipeline. Used for identification and setting from Game Objects.
The cached height of the Projection matrix.
The Projection matrix, used by shaders as 'uProjectionMatrix' uniform.
The cached width of the Projection matrix.
An array of RenderTarget instances that belong to this pipeline.
The WebGL Renderer instance to which this pipeline is bound.
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.
The primitive topology which the pipeline will use to submit draw calls.
Defaults to GL_TRIANGLES if not otherwise set in the config.
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.
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.
The current number of vertices that have been added to the pipeline batch.
Raw byte buffer of vertices.
Either set via the config object vertices
property, or generates a new Array Buffer of
size vertexCapacity * vertexSize
.
Float32 view of the array buffer containing the pipeline's vertices.
Uint32 view of the array buffer containing the pipeline's vertices.
The canvas which this WebGL Pipeline renders to.
Width of the current viewport.
Add a listener for a given event.
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. |
this
.
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
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 | WebGLTexture | <optional> |
WebGLTexture 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. |
true
if this method caused the batch to flush, otherwise false
.
Adds the vertices data into the batch and flushes if full.
Assumes 3 vertices in the following arrangement:
0
|\
| \
| \
| \
| \
1-----2
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 | WebGLTexture | <optional> |
WebGLTexture 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. |
true
if this method caused the batch to flush, otherwise false
.
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.
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. |
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.
name | type | arguments | description |
---|---|---|---|
currentShader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set as being current. |
This WebGLPipeline instance.
Activates the given Render Target texture and binds it to the requested WebGL texture slot.
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 |
This WebGL Pipeline instance.
Activates the given WebGL Texture and binds it to the requested texture slot.
name | type | arguments | description |
---|---|---|---|
target | WebGLTexture | <optional> |
The WebGLTexture to activate and bind. |
unit | number | <optional> |
The WebGL texture ID to activate. Defaults to |
This WebGL Pipeline instance.
Called when the Game has fully booted and the Renderer has finished setting up.
By this stage all Game level systems are now in place. You can perform any final tasks that the pipeline may need, that relies on game systems such as the Texture Manager being ready.
Destroys all shader instances, removes all object references and nulls all external references.
This WebGLPipeline instance.
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.
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 | WebGLTexture | <optional> |
WebGLTexture 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? |
Calls each of the listeners registered for a given event.
name | type | arguments | description |
---|---|---|---|
event | string | symbol |
The event name. |
|
args | * | <optional> |
Additional arguments that will be passed to the event handler. |
true
if the event had listeners, else false
.
Return an array listing the events for which the emitter has registered listeners.
Uploads the vertex data and emits a draw call for the current batch of vertices.
name | type | arguments | Default | description |
---|---|---|---|---|
isPostFlush | boolean | <optional> | false |
Was this flush invoked as part of a post-process, or not? |
This WebGLPipeline instance.
Searches all shaders in this pipeline for one matching the given name, then returns it.
name | type | description |
---|---|---|
name | string |
The index of the shader to set. |
The WebGLShader instance, if found.
Return the number of listeners listening to a given event.
name | type | description |
---|---|---|
event | string | symbol |
The event name. |
The number of listeners.
Return the listeners registered for a given event.
name | type | description |
---|---|---|
event | string | symbol |
The event name. |
The registered listeners.
Remove the listeners of a given event.
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. |
this
.
Add a listener for a given event.
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. |
this
.
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.
name | type | description |
---|---|---|
currentShader | Phaser.Renderer.WebGL.WebGLShader |
The shader that was set as current. |
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
.
name | type | arguments | Default | description |
---|---|---|---|---|
isPostFlush | boolean | <optional> | false |
Was this flush invoked as part of a post-process, or not? |
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.
name | type | arguments | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | <optional> |
The Game Object that invoked this pipeline, if any. |
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
.
name | type | arguments | Default | description |
---|---|---|---|---|
isPostFlush | boolean | <optional> | false |
Was this flush invoked as part of a post-process, or not? |
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.
name | type | arguments | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | <optional> |
The Game Object that invoked this pipeline, if any. |
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.
This method is only used by 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.
name | type | description |
---|---|---|
renderTarget | Phaser.Renderer.WebGL.RenderTarget |
The Render Target. |
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.
name | type | arguments | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | <optional> |
The Game Object that invoked this pipeline, if any. |
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.
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.
name | type | arguments | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | <optional> |
The Game Object that invoked this pipeline, if any. |
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.
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.
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.
name | type | description |
---|---|---|
scene | Phaser.Scene |
The Scene being rendered. |
camera | Phaser.Cameras.Scene2D.Camera |
The Scene Camera being rendered with. |
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.
name | type | description |
---|---|---|
width | number |
The new width of this WebGL Pipeline. |
height | number |
The new height of this WebGL Pipeline. |
Add a one-time listener for a given event.
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. |
this
.
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.
name | type | arguments | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera | <optional> |
The Game Object or Camera that invoked this pipeline, if any. |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera | <optional> |
The Game Object or Camera that invoked this pipeline, if any. |
This WebGLPipeline instance.
This method is called every time the Pipeline Manager rebinds this pipeline.
It resets all shaders this pipeline uses, setting their attributes again.
This WebGLPipeline instance.
Remove all listeners, or those of the specified event.
name | type | arguments | description |
---|---|---|---|
event | string | symbol | <optional> |
The event name. |
this
.
Remove the listeners of a given event.
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. |
this
.
Resizes the properties used to describe the viewport.
This method is called automatically by the renderer during its resize handler.
name | type | description |
---|---|---|
width | number |
The new width of this WebGL Pipeline. |
height | number |
The new height of this WebGL Pipeline. |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
x | number |
The new value of the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
x | number |
The new value of the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
x | number |
The new X component of the |
|
y | number |
The new Y component of the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
x | number |
The new X component of the |
|
y | number |
The new Y component of the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
x | number |
The new X component of the |
|
y | number |
The new Y component of the |
|
z | number |
The new Z component of the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
x | number |
The new X component of the |
|
y | number |
The new Y component of the |
|
z | number |
The new Z component of the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
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 |
This WebGLPipeline instance.
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.
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. |
The texture unit the Game Object has been assigned.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
transpose | boolean |
Whether to transpose the matrix. Should be |
|
matrix | Array.<number> | Float32Array |
The new values for the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
transpose | boolean |
Whether to transpose the matrix. Should be |
|
matrix | Float32Array |
The new values for the |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
name | type | arguments | description |
---|---|---|---|
name | string |
The name of the uniform to set. |
|
transpose | boolean |
Should the matrix be transpose |
|
matrix | Float32Array |
Matrix data |
|
shader | Phaser.Renderer.WebGL.WebGLShader | <optional> |
The shader to set the value on. If not given, the |
This WebGLPipeline instance.
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.
name | type | description |
---|---|---|
width | number |
The new width of this WebGL Pipeline. |
height | number |
The new height of this WebGL Pipeline. |
This WebGLPipeline instance.
Sets the currently active shader within this pipeline.
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? |
This WebGLPipeline instance.
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.
name | type | description |
---|---|---|
config | Phaser.Types.Renderer.WebGL.WebGLPipelineConfig |
The configuration object for this WebGL Pipeline. |
This WebGLPipeline instance.
Sets the texture to be bound to the next available texture unit and returns the unit id.
name | type | arguments | description |
---|---|---|---|
texture | WebGLTexture | <optional> |
WebGLTexture that will be assigned to the current batch. If not given uses |
The assigned texture unit.
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
.
name | type | description |
---|---|---|
name | string |
The name of the uniform to set. |
This WebGLPipeline instance.
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.
true
if the vertex buffer was bound, or false
if it was already bound.
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.
name | type | arguments | description |
---|---|---|---|
amount | number | <optional> |
Will the batch need to flush if this many vertices are added to it? |
true
if the current batch should be flushed, otherwise false
.
Removes all listeners.
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.
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.