Class: WebGLRenderer

PIXI. WebGLRenderer

new PIXI.WebGLRenderer(width, height, options)

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 :)

Name Type Default Description
width number 0 optional

the width of the canvas view

height number 0 optional

the height of the canvas view

options object optional

The optional renderer parameters

Name Type Default Description
view HTMLCanvasElement optional

the canvas to use as a view, optional

transparent boolean false optional

If the render view is transparent, default false

autoResize boolean false optional

If the render view is automatically resized, default false

antialias boolean false optional

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

forceFXAA boolean false optional

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

resolution number 1 optional

the resolution of the renderer retina would be 2

clearBeforeRender boolean true optional

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 false optional

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

roundPixels boolean false optional

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

Extends

Members

autoResizeboolean

Whether the render view should be resized automatically

backgroundColornumber

The background color to fill if not transparent

blendModeManagerPIXI.BlendModeManager

Manages the blendModes

blendModesobject.<string, mixed>

Tracks the blend modes useful for this renderer.

clearBeforeRenderboolean

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.

currentRendererPIXI.ObjectRenderer

The currently active ObjectRenderer.

currentRenderTargetPIXI.RenderTarget

Holds the current render target

drawCountnumber

Counter for the number of draws made each frame

filterManagerPIXI.FilterManager

Manages the filters.

heightnumber

The height of the canvas view

Default Value:
  • 600

maskManagerPIXI.MaskManager

Manages the masks using the stencil buffer.

preserveDrawingBufferboolean

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

resolutionnumber

The resolution of the renderer

Default Value:
  • 1

roundPixelsboolean

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

shaderManagerPIXI.ShaderManager

Deals with managing the shader programs and their attribs.

stencilManagerPIXI.StencilManager

Manages the stencil buffer.

transparentboolean

Whether the render view is transparent

typenumber

The type of this renderer as a standardised const

viewHTMLCanvasElement

The canvas element that everything is drawn to

widthnumber

The width of the canvas view

Default Value:
  • 800

Methods

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

Name Type Default Description
removeView boolean false optional

Removes the Canvas element from the DOM.

Deletes the texture from WebGL

Name Type Description
texture PIXI.BaseTexture | PIXI.Texture

the texture to destroy

Renders the object to its webGL view

Name Type Description
object PIXI.DisplayObject

the object to be rendered

renderDisplayObject(displayObject, renderTarget)

Renders a Display Object.

Name Type Description
displayObject PIXI.DisplayObject

The DisplayObject to render

renderTarget PIXI.RenderTarget

The render target to use to render this display object

Resizes the webGL view to the specified width and height.

Name Type Description
width number

the new width of the webGL view

height number

the new height of the webGL view

setObjectRenderer(objectRenderer)

Changes the current renderer to the one given in parameter

Name Type Description
objectRenderer PIXI.ObjectRenderer

The object renderer to use.

setRenderTarget(renderTarget)

Changes the current render target to the one given in parameter

Name Type Description
renderTarget PIXI.RenderTarget

the new render target

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

Name Type Description
texture PIXI.BaseTexture | PIXI.Texture

the texture to update