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
|
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
-
destroy(removeView)
-
Removes everything from the renderer (event listeners, spritebatch, etc...)
Name Type Default Description removeView
boolean false optional Removes the Canvas element from the DOM.
-
destroyTexture(texture)
-
Deletes the texture from WebGL
Name Type Description texture
PIXI.BaseTexture | PIXI.Texture the texture to destroy
-
render(object)
-
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
-
resize(width, height)
-
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
-
updateTexture(texture)
-
Updates and/or Creates a WebGL texture for the renderer's context.
Name Type Description texture
PIXI.BaseTexture | PIXI.Texture the texture to update