Class: WebGLRenderer

PIXI. WebGLRenderer

new WebGLRenderer(game)

The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs. So no need for Sprite Batches or Sprite Clouds. Don't forget to add the view to your DOM or you will not see anything :)

Parameters:
Name Type Description
game Phaser.Game

A reference to the Phaser Game instance

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 19

Members

autoResize : Boolean

Whether the render view should be resized automatically

Type:
  • Boolean
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 57

blendModeManager : WebGLBlendModeManager

Manages the blendModes

Type:
  • WebGLBlendModeManager
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 182

clearBeforeRender : Boolean

This sets if the WebGLRenderer will clear the context texture or not before the new render pass. If true: If the Stage is NOT transparent, Pixi will clear to alpha (0, 0, 0, 0). If the Stage is transparent, Pixi will clear to the target Stage's background color. Disable this by setting this to false. For example: if your game has a canvas filling background image, you often don't need this set.

Type:
  • Boolean
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 77

currentBatchedTextures : Array

Type:
  • Array
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 194

filterManager : WebGLFilterManager

Manages the filters

Type:
  • WebGLFilterManager
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 168

game : Phaser.Game

A reference to the Phaser Game instance.

Type:
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 24

height : Number

The height of the canvas view

Type:
  • Number
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 103

maskManager : WebGLMaskManager

Manages the masks using the stencil buffer

Type:
  • WebGLMaskManager
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 161

offset : Point

Type:
  • Point
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 138

<readonly> powerPreference : string

The "powerPreference" attribute the WebGL context was created with.

Type:
  • string
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 87

preserveDrawingBuffer : Boolean

The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering.

Type:
  • Boolean
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 65

projection : Point

Type:
  • Point
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 132

renderSession : Object

Type:
  • Object
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 188

resolution : Number

The resolution of the renderer

Type:
  • Number
Default Value:
  • 1
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 41

shaderManager : WebGLShaderManager

Deals with managing the shader programs and their attribs

Type:
  • WebGLShaderManager
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 147

spriteBatch : WebGLSpriteBatch

Manages the rendering of sprites

Type:
  • WebGLSpriteBatch
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 154

stencilManager : WebGLStencilManager

Manages the stencil buffer

Type:
  • WebGLStencilManager
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 175

transparent : Boolean

Whether the render view is transparent

Type:
  • Boolean
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 49

type : Number

Type:
  • Number
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 32

view : HTMLCanvasElement

The canvas element that everything is drawn to

Type:
  • HTMLCanvasElement
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 111

width : Number

The width of the canvas view

Type:
  • Number
Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 95

Methods

destroy()

Removes everything from the renderer (event listeners, spritebatch, etc...)

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 599

initContext()

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 221

mapBlendModes()

Maps Pixi blend modes to WebGL blend modes.

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 631

render(stage)

Renders the stage to its webGL view

Parameters:
Name Type Description
stage Stage

the Stage element to be rendered

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 373

renderDisplayObject(displayObject, projection, buffer)

Renders a Display Object.

Parameters:
Name Type Description
displayObject DisplayObject

The DisplayObject to render

projection Point

The projection

buffer Array

a standard WebGL buffer

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 414

resize(width, height)

Resizes the webGL view to the specified width and height.

Parameters:
Name Type Description
width Number

the new width of the webGL view

height Number

the new height of the webGL view

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 451

setTexturePriority(textureNameCollection)

If Multi Texture support has been enabled, then calling this method will enable batching on the given textures. The texture collection is an array of keys, that map to Phaser.Cache image entries.

The number of textures that can be batched is dependent on hardware. If you provide more textures than can be batched by the GPU, then only those at the start of the array will be used. Generally you shouldn't provide more than 16 textures to this method. You can check the hardware limit via the maxTextures property.

You can also check the property currentBatchedTextures at any time, to see which textures are currently being batched.

To stop all textures from being batched, call this method again with an empty array.

To change the textures being batched, call this method with a new array of image keys. The old ones will all be purged out and no-longer batched, and the new ones enabled.

Note: Throws a warning if you haven't enabled Multiple Texture batching support in the Phaser Game config.

Parameters:
Name Type Description
textureNameCollection Array

An Array of Texture Cache keys to use for multi-texture batching.

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 275
Returns:

An array containing the texture keys that were enabled for batching.

Type
Array

updateCompressedTexture(texture)

Updates and creates a WebGL compressed texture for the renderers context.

Parameters:
Name Type Description
texture Texture

the texture to update

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 478
Returns:

True if the texture was successfully bound, otherwise false.

Type
boolean

updateTexture(texture)

Updates and Creates a WebGL texture for the renderers context.

Parameters:
Name Type Description
texture Texture

the texture to update

Source:
src/pixi/renderers/webgl/WebGLRenderer.js line 538
Returns:

True if the texture was successfully bound, otherwise false.

Type
boolean

phaser-ce@2.20.0 is on GitHub and NPM

Documentation generated by JSDoc 3.6.7 on 2022-12-10 using Tomorrow.