#

API Docs for: 1.6.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 webGLBatch's. So no need for Sprite Batch's or Sprite Cloud's Dont forget to add the view to your DOM or you will not see anything :)

## Constructor

### `WebGLRenderer`

(

- `width=0`
- `height=0`
- `view`
- `transparent=false`
- `antialias=false`
- `preserveDrawingBuffer=false`

)

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

#### Parameters:

- `width=0` Number

  the width of the canvas view

- `height=0` Number

  the height of the canvas view

- `view` HTMLCanvasElement

  the canvas to use as a view, optional

- `transparent=false` Boolean

  If the render view is transparent, default false

- `antialias=false` Boolean

  sets antialias (only applicable in chrome at the moment)

- `preserveDrawingBuffer=false` Boolean

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

- Index
- Methods
- Properties

## Item Index

### Methods

- createWebGLTexture static
- destroy
- destroyTexture
- handleContextLost
- handleContextRestored
- render
- renderDIsplayObject
- resize
- updateTextureFrame
- updateTextures static
- updateWebGLTexture

### Properties

- contextLost
- height
- preserveDrawingBuffer
- transparent
- view
- width

## Methods

### `createWebGLTexture`

(

- `texture`
- `gl`

)
static

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

Creates a WebGL texture

#### Parameters:

- `texture` Texture

  the texture to render

- `gl` WebglContext

  the WebGL context

### `destroy`

()

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

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

### `destroyTexture`

(

- `texture`

)
private

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

Destroys a loaded webgl texture

#### Parameters:

- `texture` Texture

  The texture to update

### `handleContextLost`

(

- `event`

)
private

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

Handles a lost webgl context

#### Parameters:

- `event` Event

### `handleContextRestored`

(

- `event`

)
private

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

Handles a restored webgl context

#### Parameters:

- `event` Event

### `render`

(

- `stage`

)

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

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:282`

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:384`

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

### `updateTextureFrame`

(

- `texture`

)
private

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

#### Parameters:

- `texture` Texture

  The texture to update the frame from

### `updateTextures`

() private static

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

Updates the textures loaded into this webgl renderer

### `updateWebGLTexture`

(

- `texture`
- `gl`

)
private

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

Updates a WebGL texture

#### Parameters:

- `texture` Texture

  the texture to update

- `gl` WebglContext

  the WebGL context

## Properties

### `contextLost`

Boolean

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

Whether the context was lost

### `height`

Number

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

The height of the canvas view

Default: 600

### `preserveDrawingBuffer`

Boolean

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

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

### `transparent`

Boolean

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

Whether the render view is transparent

### `view`

HTMLCanvasElement

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

The canvas element that everything is drawn to

### `width`

Number

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

The width of the canvas view

Default: 800