#

API Docs for: 2.0.0
Show: Inherited Protected Private Deprecated

# WebGLRenderer Class

Defined in: `src/pixi/renderers/webgl/WebGLRenderer.js:7`
Module: PIXI

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

## Constructor

### `WebGLRenderer`

(

- `[width=0]`
- `[height=0]`
- `[options]`

)

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:7`

#### Parameters:

- `[width=0]` Number optional

  the width of the canvas view

- `[height=0]` Number optional

  the height of the canvas view

- `[options]` Object optional

  The optional renderer parameters

  - `[view]` HTMLCanvasElement optional

    the canvas to use as a view, optional

  - `[transparent=false]` Boolean optional

    If the render view is transparent, default false

  - `[antialias=false]` Boolean optional

    sets antialias (only applicable in chrome at the moment)

  - `[preserveDrawingBuffer=false]` Boolean optional

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

  - `[resolution=1]` Number optional

    the resolution of the renderer retina would be 2

- Index
- Methods
- Properties

## Item Index

### Methods

- destroy
- handleContextLost
- handleContextRestored
- initContext
- mapBlendModes
- render
- renderDisplayObject
- resize
- updateTexture

### Properties

- _contextOptions
- blendModeManager
- clearBeforeRender
- contextLostBound
- contextRestoredBound
- filterManager
- height
- maskManager
- offset
- preserveDrawingBuffer
- projection
- renderSession
- resolution
- shaderManager
- spriteBatch
- stencilManager
- transparent
- type
- view
- width

## Methods

### `destroy`

()

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:460`

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

### `handleContextLost`

(

- `event`

)
private

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:426`

Handles a lost webgl context

#### Parameters:

- `event` Event

### `handleContextRestored`

(

- `event`

)
private

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:439`

Handles a restored webgl context

#### Parameters:

- `event` Event

### `initContext`

()

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:228`

### `mapBlendModes`

()

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:491`

Maps Pixi blend modes to WebGL blend modes.

### `render`

(

- `stage`

)

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:264`

Renders the stage to its webGL view

#### Parameters:

- `stage` Stage

  the Stage element to be rendered

### `renderDisplayObject`

(

- `displayObject`
- `projection`
- `buffer`

)

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:332`

Renders a Display Object.

#### Parameters:

- `displayObject` DisplayObject

  The DisplayObject to render

- `projection` Point

  The projection

- `buffer` Array

  a standard WebGL buffer

### `resize`

(

- `width`
- `height`

)

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:366`

Resizes the webGL view to the specified width and height.

#### Parameters:

- `width` Number

  the new width of the webGL view

- `height` Number

  the new height of the webGL view

### `updateTexture`

(

- `texture`

)

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:387`

Updates and Creates a WebGL texture for the renderers context.

#### Parameters:

- `texture` Texture

  the texture to update

## Properties

### `_contextOptions`

Object private

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:132`

### `blendModeManager`

WebGLBlendModeManager

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:194`

Manages the blendModes

### `clearBeforeRender`

Boolean

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:77`

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.

### `contextLostBound`

Function

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:117`

### `contextRestoredBound`

Function

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:123`

### `filterManager`

WebGLFilterManager

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:180`

Manages the filters

### `height`

Number

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:98`

The height of the canvas view

Default: 600

### `maskManager`

WebGLMaskManager

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:173`

Manages the masks using the stencil buffer

### `offset`

Point

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:151`

### `preserveDrawingBuffer`

Boolean

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:69`

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

### `projection`

Point

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:145`

### `renderSession`

Object

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:201`

TODO remove

### `resolution`

Number

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:50`

The resolution of the renderer

Default: 1

### `shaderManager`

WebGLShaderManager

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:159`

Deals with managing the shader programs and their attribs

### `spriteBatch`

WebGLSpriteBatch

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:166`

Manages the rendering of sprites

### `stencilManager`

WebGLStencilManager

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:187`

Manages the stencil buffer

### `transparent`

Boolean

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:61`

Whether the render view is transparent

### `type`

Number

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:44`

### `view`

HTMLCanvasElement

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:107`

The canvas element that everything is drawn to

### `width`

Number

Defined in `src/pixi/renderers/webgl/WebGLRenderer.js:89`

The width of the canvas view

Default: 800