Class: WebGLRenderer

WebGLRenderer

The WebGLRenderer draws the scene 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 :)


new WebGLRenderer( [width] [, height] [, options])

Parameters:
Name Type Argument Default Description
width number <optional>
0

the width of the canvas view

height number <optional>
0

the height of the canvas view

options object <optional>

The optional renderer parameters

Properties
Name Type Argument Default Description
view HTMLCanvasElement <optional>

the canvas to use as a view, optional

transparent boolean <optional>
false

If the render view is transparent, default false

autoResize boolean <optional>
false

If the render view is automatically resized, default false

antialias boolean <optional>
false

sets antialias. If not available natively then FXAA antialiasing is used

forceFXAA boolean <optional>
false

forces FXAA antialiasing to be used over native. FXAA is faster, but may not always look as great

resolution number <optional>
1

the resolution of the renderer retina would be 2

clearBeforeRender boolean <optional>
true

This sets if the CanvasRenderer will clear the canvas or
not before the new render pass. If you wish to set this to false, you must set preserveDrawingBuffer to true.

preserveDrawingBuffer boolean <optional>
false

enables drawing buffer preservation, enable this if
you need to call toDataUrl on the webgl context.

roundPixels boolean <optional>
false

If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation.

Source:

Extends

Members


autoResize :boolean

Whether the render view should be resized automatically

Type:
  • boolean
Inherited From:
Source:

backgroundColor :number

The background color to fill if not transparent

Type:
  • number
Inherited From:
Source:

blendModeManager :BlendModeManager

Manages the blendModes

Type:
Source:

blendModes :object.<string, mixed>

Tracks the blend modes useful for this renderer.

Type:
  • object.<string, mixed>
Inherited From:
Overrides:
Source:

clearBeforeRender :boolean

This sets if the CanvasRenderer will clear the canvas or not before the new render pass.
If the scene is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color.
If the scene is transparent Pixi will use clearRect to clear the canvas every frame.
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
Inherited From:
Source:

currentRenderer :ObjectRenderer

The currently active ObjectRenderer.

Type:
Source:

currentRenderTarget :RenderTarget

Holds the current render target

Type:
Source:

drawCount :number

Counter for the number of draws made each frame

Type:
  • number
Source:

filterManager :FilterManager

Manages the filters.

Type:
Source:

height :number

The height of the canvas view

Type:
  • number
Inherited From:
Default Value:
  • 600
Source:

maskManager :MaskManager

Manages the masks using the stencil buffer.

Type:
Source:

preserveDrawingBuffer :boolean

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

Type:
  • boolean
Inherited From:
Source:

resolution :number

The resolution of the renderer

Type:
  • number
Inherited From:
Default Value:
  • 1
Source:

roundPixels :boolean

If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation.
Handy for crisp pixel art and speed on legacy devices.

Type:
  • boolean
Inherited From:
Source:

shaderManager :ShaderManager

Deals with managing the shader programs and their attribs.

Type:
Source:

stencilManager :StencilManager

Manages the stencil buffer.

Type:
  • StencilManager
Source:

transparent :boolean

Whether the render view is transparent

Type:
  • boolean
Inherited From:
Source:

type :number

The type of this renderer as a standardised const

Type:
  • number
Overrides:
Source:

view :HTMLCanvasElement

The canvas element that everything is drawn to

Type:
  • HTMLCanvasElement
Inherited From:
Source:

width :number

The width of the canvas view

Type:
  • number
Inherited From:
Default Value:
  • 800
Source:

Methods


destroy( [removeView])

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

Parameters:
Name Type Argument Default Description
removeView boolean <optional>
false

Removes the Canvas element from the DOM.

Overrides:
Source:

destroyTexture(texture)

Deletes the texture from WebGL

Parameters:
Name Type Description
texture BaseTexture | Texture

the texture to destroy

Source:

render(object)

Renders the object to its webGL view

Parameters:
Name Type Description
object DisplayObject

the object to be rendered

Source:

renderDisplayObject(displayObject, renderTarget)

Renders a Display Object.

Parameters:
Name Type Description
displayObject DisplayObject

The DisplayObject to render

renderTarget RenderTarget

The render target to use to render this display object

Source:

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

Overrides:
Source:

setObjectRenderer(objectRenderer)

Changes the current renderer to the one given in parameter

Parameters:
Name Type Description
objectRenderer ObjectRenderer

The object renderer to use.

Source:

setRenderTarget(renderTarget)

Changes the current render target to the one given in parameter

Parameters:
Name Type Description
renderTarget RenderTarget

the new render target

Source:

updateTexture(texture)

Updates and/or Creates a WebGL texture for the renderer's context.

Parameters:
Name Type Description
texture BaseTexture | Texture

the texture to update

Source: