Class: WebGLRenderer

Phaser.Renderer.WebGL. WebGLRenderer

WebGLRenderer is a class that contains the needed functionality to keep the
WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of
any context change that happens for WebGL rendering inside of Phaser. This means
if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL
rendering ecosystem they might pollute the current WebGLRenderingContext state producing
unexpected behavior. It's recommended that WebGL interaction is done through
WebGLRenderer and/or WebGLPipeline.


new WebGLRenderer(game)

Parameters:
Name Type Description
game Phaser.Game

The Game instance which owns this WebGL Renderer.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 36)

Members


<readonly> blankTexture :WebGLTexture

A blank 32x32 transparent texture, as used by the Graphics system where needed.
This is set in the boot method.

Type:
  • WebGLTexture
Since: 3.12.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 414)

blendModes :array

An array of blend modes supported by the WebGL Renderer.

This array includes the default blend modes as well as any custom blend modes added through #addBlendMode.

Type:
  • array
Since: 3.0.0
Default Value:
  • []
Source: src/renderer/webgl/WebGLRenderer.js (Line 159)

canvas :HTMLCanvasElement

The canvas which this WebGL Renderer draws to.

Type:
  • HTMLCanvasElement
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 132)

compression :array

Stores the supported WebGL texture compression formats.

Type:
  • array
Since: 3.8.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 391)

config :RendererConfig

The local configuration settings of this WebGL Renderer.

Type:
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 75)

contextLost :boolean

Set to true if the WebGL context of the renderer is lost.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/renderer/webgl/WebGLRenderer.js (Line 181)

currentActiveTextureUnit :integer

Cached value for the last texture unit that was used

Type:
  • integer
Since: 3.1.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 218)

currentBlendMode :integer

Current blend mode in use

Type:
  • integer
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 286)

currentFramebuffer :WebGLFramebuffer

Current framebuffer in use

Type:
  • WebGLFramebuffer
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 236)

currentIndexBuffer :WebGLBuffer

Current WebGLBuffer (Index buffer) in use

Type:
  • WebGLBuffer
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 276)

currentPipeline :Phaser.Renderer.WebGL.WebGLPipeline

Current WebGLPipeline in use

Type:
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 246)

currentProgram :WebGLProgram

Current WebGLProgram in use

Type:
  • WebGLProgram
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 256)

currentScissor :Uint32Array

Stores the current scissor data

Type:
  • Uint32Array
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 305)

currentScissorEnabled :boolean

Indicates if the the scissor state is enabled in WebGLRenderingContext

Type:
  • boolean
Since: 3.0.0
Default Value:
  • false
Source: src/renderer/webgl/WebGLRenderer.js (Line 295)

currentTextures :array

An array of the last texture handles that were bound to the WebGLRenderingContext

Type:
  • array
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 227)

currentVertexBuffer :WebGLBuffer

Current WebGLBuffer (Vertex buffer) in use

Type:
  • WebGLBuffer
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 266)

<readonly> drawingBufferHeight :number

Cached drawing buffer height to reduce gl calls.

Type:
  • number
Since: 3.11.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 404)

extensions :object

Extensions loaded into the current context

Type:
  • object
Since: 3.0.0
Default Value:
  • {}
Source: src/renderer/webgl/WebGLRenderer.js (Line 371)

game :Phaser.Game

The Game instance which owns this WebGL Renderer.

Type:
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 96)

gl :WebGLRenderingContext

The underlying WebGL context of the renderer.

Type:
  • WebGLRenderingContext
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 351)

glFormats :array

Stores the current WebGL component formats for further use

Type:
  • array
Since: 3.2.0
Default Value:
  • []
Source: src/renderer/webgl/WebGLRenderer.js (Line 381)

height :integer

The height of the canvas being rendered to.

Type:
  • integer
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 123)

lostContextCallbacks :Array.<WebGLContextCallback>

An array of functions to invoke if the WebGL context is lost.

Type:
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 141)

nativeTextures :array

Keeps track of any WebGLTexture created with the current WebGLRenderingContext

Type:
  • array
Since: 3.0.0
Default Value:
  • []
Source: src/renderer/webgl/WebGLRenderer.js (Line 171)

pipelines :object

This object will store all pipelines created through addPipeline

Type:
  • object
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 191)

restoredContextCallbacks :Array.<WebGLContextCallback>

An array of functions to invoke if the WebGL context is restored.

Type:
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 150)

scissorStack :Uint32Array

Stack of scissor data

Type:
  • Uint32Array
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 315)

snapshotState :SnapshotState

Details about the currently scheduled snapshot.

If a non-null callback is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered.

Type:
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 201)

supportedExtensions :object

Array of strings that indicate which WebGL extensions are supported by the browser

Type:
  • object
Since: 3.0.0
Default Value:
  • null
Source: src/renderer/webgl/WebGLRenderer.js (Line 361)

type :integer

A constant which allows the renderer to be easily identified as a WebGL Renderer.

Type:
  • integer
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 105)

width :integer

The width of the canvas being rendered to.

Type:
  • integer
Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 114)

Methods


addBlendMode(func, equation)

Creates a new custom blend mode for the renderer.

Parameters:
Name Type Description
func function

An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for WebGLRenderingContext#blendFunc().

equation function

The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for WebGLRenderingContext#blendEquation().

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 964)
Returns:

The index of the new blend mode, used for referencing it in the future.

Type
integer

addPipeline(pipelineName, pipelineInstance)

Adds a pipeline instance into the collection of pipelines

Parameters:
Name Type Description
pipelineName string

A unique string-based key for the pipeline.

pipelineInstance Phaser.Renderer.WebGL.WebGLPipeline

A pipeline instance which must extend WebGLPipeline.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 778)
Returns:

The pipline instance that was passed.

Type
Phaser.Renderer.WebGL.WebGLPipeline

canvasToTexture(srcCanvas [, dstTexture] [, noRepeat])

Creates a WebGL Texture based on the given canvas element.

Parameters:
Name Type Argument Default Description
srcCanvas HTMLCanvasElement

The Canvas element that will be used to populate the texture.

dstTexture WebGLTexture <optional>

Is this going to replace an existing texture? If so, pass it here.

noRepeat boolean <optional>
false

Should this canvas never be allowed to set REPEAT? (such as for Text objects)

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1811)
Returns:

The newly created WebGL Texture.

Type
WebGLTexture

createFramebuffer(width, height, renderTexture, addDepthStencilBuffer)

Wrapper for creating WebGLFramebuffer.

Parameters:
Name Type Description
width integer

Width in pixels of the framebuffer

height integer

Height in pixels of the framebuffer

renderTexture WebGLTexture

The color texture to where the color pixels are written

addDepthStencilBuffer boolean

Indicates if the current framebuffer support depth and stencil buffers

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1304)
Returns:

Raw WebGLFramebuffer

Type
WebGLFramebuffer

createIndexBuffer(initialDataOrSize, bufferUsage)

Wrapper for creating a vertex buffer.

Parameters:
Name Type Description
initialDataOrSize ArrayBuffer

Either ArrayBuffer or an integer indicating the size of the vbo.

bufferUsage integer

How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1428)
Returns:

Raw index buffer

Type
WebGLBuffer

createProgram(vertexShader, fragmentShader)

Wrapper for creating a WebGLProgram

Parameters:
Name Type Description
vertexShader string

Source to the vertex shader

fragmentShader string

Source to the fragment shader

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1359)
Returns:

Raw WebGLProgram

Type
WebGLProgram

createTexture2D(mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma)

A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture.

Parameters:
Name Type Description
mipLevel integer

Mip level of the texture.

minFilter integer

Filtering of the texture.

magFilter integer

Filtering of the texture.

wrapT integer

Wrapping mode of the texture.

wrapS integer

Wrapping mode of the texture.

format integer

Which format does the texture use.

pixels object

pixel data.

width integer

Width of the texture in pixels.

height integer

Height of the texture in pixels.

pma boolean

Does the texture have premultiplied alpha?

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1247)
Returns:

The WebGLTexture that was created.

Type
WebGLTexture

createTextureFromSource(source, width, height, scaleMode)

Creates a texture from an image source. If the source is not valid it creates an empty texture.

Parameters:
Name Type Description
source object

The source of the texture.

width integer

The width of the texture.

height integer

The height of the texture.

scaleMode integer

The scale mode to be used by the texture.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1202)
Returns:

The WebGL Texture that was created, or null if it couldn't be created.

Type
WebGLTexture

createVertexBuffer(initialDataOrSize, bufferUsage)

Wrapper for creating a vertex buffer.

Parameters:
Name Type Description
initialDataOrSize ArrayBuffer

It's either ArrayBuffer or an integer indicating the size of the vbo

bufferUsage integer

How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1403)
Returns:

Raw vertex buffer

Type
WebGLBuffer

deleteBuffer(vertexBuffer)

Deletes a WebGLBuffer from the GL instance.

Parameters:
Name Type Description
vertexBuffer WebGLBuffer

The WebGLBuffer to be deleted.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1517)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

deleteFramebuffer(framebuffer)

Deletes a WebGLFramebuffer from the GL instance.

Parameters:
Name Type Description
framebuffer WebGLFramebuffer

The Framebuffer to be deleted.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1483)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

deleteProgram(program)

Deletes a WebGLProgram from the GL instance.

Parameters:
Name Type Description
program WebGLProgram

The shader program to be deleted.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1500)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

deleteTexture(texture)

Removes the given texture from the nativeTextures array and then deletes it from the GPU.

Parameters:
Name Type Description
texture WebGLTexture

The WebGL Texture to be deleted.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1453)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

destroy()

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2240)

flush()

Flushes the current pipeline if the pipeline is bound

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 717)

getExtension(extensionName)

Loads a WebGL extension

Parameters:
Name Type Description
extensionName string

The name of the extension to load.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 695)
Returns:

WebGL extension if the extension is supported

Type
object

getMaxTextures()

Returns the maximum number of texture units that can be used in a fragment shader.

Since: 3.8.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2212)
Returns:

The maximum number of textures WebGL supports.

Type
integer

getMaxTextureSize()

Returns the largest texture size (either width or height) that can be created.
Note that VRAM may not allow a texture of any given size, it just expresses
hardware / driver support for a given size.

Since: 3.8.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2225)
Returns:

The maximum supported texture size.

Type
integer

getPipeline(pipelineName)

Returns the pipeline by name if the pipeline exists

Parameters:
Name Type Description
pipelineName string

The name of the pipeline.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 746)
Returns:

The pipeline instance, or null if not found.

Type
Phaser.Renderer.WebGL.WebGLPipeline

hasExtension(extensionName)

Checks if a WebGL extension is supported

Parameters:
Name Type Description
extensionName string

Name of the WebGL extension

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 680)
Returns:

true if the extension is supported, otherwise false.

Type
boolean

hasPipeline(pipelineName)

Checks if a pipeline is present in the current WebGLRenderer

Parameters:
Name Type Description
pipelineName string

The name of the pipeline.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 731)
Returns:

true if the given pipeline is loaded, otherwise false.

Type
boolean

init(config)

Creates a new WebGLRenderingContext and initializes all internal
state.

Parameters:
Name Type Description
config object

The configuration object for the renderer.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 470)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

onContextLost(callback, target)

Adds a callback to be invoked when the WebGL context has been lost by the browser.

Parameters:
Name Type Description
callback WebGLContextCallback

The callback to be invoked on context loss.

target object

The context of the callback.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 662)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

onContextRestored(callback, target)

Adds a callback to be invoked when the WebGL context has been restored by the browser.

Parameters:
Name Type Description
callback WebGLContextCallback

The callback to be invoked on context restoration.

target object

The context of the callback.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 644)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

popScissor()

Pops the last scissor state and sets it.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 871)

postRender()

The post-render step happens after all Cameras in all Scenes have been rendered.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1762)

postRenderCamera(camera)

Controls the post-render operations for the given camera.
Renders the foreground camera effects like flash and fading. It resets the current scissor state.

Parameters:
Name Type Description
camera Phaser.Cameras.Scene2D.Camera

The Camera to post-render.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1596)

preRender()

Clears the current vertex buffer and updates pipelines.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1657)

preRenderCamera(camera)

Controls the pre-render operations for the given camera.
Handles any clipping needed by the camera and renders the background color if a color is visible.

Parameters:
Name Type Description
camera Phaser.Cameras.Scene2D.Camera

The Camera to pre-render.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1534)

pushScissor(x, y, width, height)

Pushes a new scissor state. This is used to set nested scissor states.

Parameters:
Name Type Description
x integer

The x position of the scissor.

y integer

The y position of the scissor.

width integer

The width of the scissor.

height integer

The height of the scissor.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 807)
Returns:

An array containing the scissor values.

Type
Array.<integer>

removeBlendMode(index)

Removes a custom blend mode from the renderer.
Any Game Objects still using this blend mode will error, so be sure to clear them first.

Parameters:
Name Type Description
index integer

The index of the custom blend mode to be removed.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1009)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

removePipeline(pipelineName)

Removes a pipeline by name.

Parameters:
Name Type Description
pipelineName string

The name of the pipeline to be removed.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 761)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

render(scene, children, interpolationPercentage, camera)

The core render step for a Scene.
Iterates through the given Game Object's array and renders them with the given Camera.

Parameters:
Name Type Description
scene Phaser.Scene

The Scene to render.

children Phaser.GameObjects.GameObject

The Game Object's within the Scene to be rendered.

interpolationPercentage number

The interpolation percentage to apply. Currently un-used.

camera Phaser.Cameras.Scene2D.Camera

The Scene Camera to render with.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1698)

resize(width, height)

Resizes the drawing buffer.

Parameters:
Name Type Description
width number

The width of the renderer.

height number

The height of the renderer.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 598)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setBlendMode(blendModeId)

Sets the blend mode to the value given.

If the current blend mode is different from the one given, the pipeline is flushed and the new
blend mode is enabled.

Parameters:
Name Type Description
blendModeId integer

The blend mode to be set. Can be a BlendModes const or an integer value.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 922)
Returns:

true if the blend mode was changed as a result of this call, forcing a flush, otherwise false.

Type
boolean

setFloat1(program, name, x)

[description]

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x number

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1881)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFloat1v(program, name, arr)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1971)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFloat2(program, name, x, y)

[description]

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x number

[description]

y number

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1902)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFloat2v(program, name, arr)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1992)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFloat3(program, name, x, y, z)

[description]

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x number

[description]

y number

[description]

z number

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1924)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFloat3v(program, name, arr)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2013)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFloat4(program, name, x, y, z, w)

Sets uniform of a WebGLProgram

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x number

X component

y number

Y component

z number

Z component

w number

W component

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1947)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFloat4v(program, name, arr)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2034)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setFramebuffer(framebuffer)

Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush.

Parameters:
Name Type Description
framebuffer WebGLFramebuffer

The framebuffer that needs to be bound.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1085)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setIndexBuffer(indexBuffer)

Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush.

Parameters:
Name Type Description
indexBuffer WebGLBuffer

The buffer the needs to be bound.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1176)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setInt1(program, name, x)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x integer

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2056)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setInt2(program, name, x, y)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x integer

[description]

y integer

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2077)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setInt3(program, name, x, y, z)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x integer

[description]

y integer

[description]

z integer

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2099)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setInt4(program, name, x, y, z, w)

Sets the value of a uniform variable in the given WebGLProgram.

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

x integer

X component

y integer

Y component

z integer

Z component

w integer

W component

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2122)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setMatrix2(program, name, transpose, matrix)

[description]

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

transpose boolean

[description]

matrix Float32Array

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2146)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setMatrix3(program, name, transpose, matrix)

[description]

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

transpose boolean

[description]

matrix Float32Array

[description]

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2168)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setMatrix4(program, name, transpose, matrix)

Sets uniform of a WebGLProgram

Parameters:
Name Type Description
program WebGLProgram

The target WebGLProgram from which the uniform location will be looked-up.

name string

The name of the uniform to look-up and modify.

transpose boolean

Is the matrix transposed

matrix Float32Array

Matrix data

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 2190)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setPipeline(pipelineInstance [, gameObject])

Binds a WebGLPipeline and sets it as the current pipeline to be used.

Parameters:
Name Type Argument Description
pipelineInstance Phaser.Renderer.WebGL.WebGLPipeline

The pipeline instance to be activated.

gameObject Phaser.GameObjects.GameObject <optional>

The Game Object that invoked this pipeline, if any.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 895)
Returns:

The pipeline that was activated.

Type
Phaser.Renderer.WebGL.WebGLPipeline

setProgram(program)

Binds a program. If there was another program already bound it will force a pipeline flush.

Parameters:
Name Type Description
program WebGLProgram

The program that needs to be bound.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1124)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setScissor(x, y, width, height)

Sets the current scissor state.

Parameters:
Name Type Description
x integer

The x position of the scissor.

y integer

The y position of the scissor.

width integer

The width of the scissor.

height integer

The height of the scissor.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 835)

setTexture2D(texture, textureUnit)

Binds a texture at a texture unit. If a texture is already
bound to that unit it will force a flush on the current pipeline.

Parameters:
Name Type Description
texture WebGLTexture

The WebGL texture that needs to be bound.

textureUnit integer

The texture unit to which the texture will be bound.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1050)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setTextureFilter(texture, filter)

Sets the minification and magnification filter for a texture.

Parameters:
Name Type Description
texture integer

The texture to set the filter for.

filter integer

The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1855)
Returns:

This WebGL Renderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

setVertexBuffer(vertexBuffer)

Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush.

Parameters:
Name Type Description
vertexBuffer WebGLBuffer

The buffer that needs to be bound.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1150)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer

snapshot(callback, type, encoderOptions)

Schedules a snapshot to be taken after the current frame is rendered.

Parameters:
Name Type Description
callback SnapshotCallback

Function to invoke after the snapshot is created.

type string

The format of the image to create, usually image/png.

encoderOptions number

The image quality, between 0 and 1, to use for image formats with lossy compression (such as image/jpeg).

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 1790)
Returns:

This WebGL Renderer.

Type
Phaser.Renderer.WebGL.WebGLRenderer

updateBlendMode(index, func, equation)

Updates the function bound to a given custom blend mode.

Parameters:
Name Type Description
index integer

The index of the custom blend mode.

func function

The function to use for the blend mode.

equation function

The equation to use for the blend mode.

Since: 3.0.0
Source: src/renderer/webgl/WebGLRenderer.js (Line 982)
Returns:

This WebGLRenderer instance.

Type
Phaser.Renderer.WebGL.WebGLRenderer