WebGLRenderer Class
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
Parameters:
-
width=0Numberthe width of the canvas view
-
height=0Numberthe height of the canvas view
-
viewHTMLCanvasElementthe canvas to use as a view, optional
-
transparent=falseBooleanIf the render view is transparent, default false
-
antialias=falseBooleansets antialias (only applicable in chrome at the moment)
-
preserveDrawingBuffer=falseBooleanenables drawing buffer preservation, enable this if you need to call toDataUrl on the webgl context
Item Index
Methods
Properties
Methods
createWebGLTexture
-
texture -
gl
Creates a WebGL texture
Parameters:
-
textureTexturethe texture to render
-
glWebglContextthe WebGL context
destroy
()
Removes everything from the renderer (event listeners, spritebatch, etc...)
destroyTexture
-
texture
Destroys a loaded webgl texture
Parameters:
-
textureTextureThe texture to update
handleContextLost
-
event
Handles a lost webgl context
Parameters:
-
eventEvent
handleContextRestored
-
event
Handles a restored webgl context
Parameters:
-
eventEvent
render
-
stage
Renders the stage to its webGL view
Parameters:
-
stageStagethe Stage element to be rendered
renderDIsplayObject
-
displayObject -
projection -
buffer
Renders a display Object
Parameters:
-
displayObjectDisplayObjectThe DisplayObject to render
-
projectionPointThe projection
-
bufferArraya standard WebGL buffer
resize
-
width -
height
resizes the webGL view to the specified width and height
Parameters:
-
widthNumberthe new width of the webGL view
-
heightNumberthe new height of the webGL view
updateTextureFrame
-
texture
Parameters:
-
textureTextureThe texture to update the frame from
updateTextures
()
private
static
Updates the textures loaded into this webgl renderer
updateWebGLTexture
-
texture -
gl
Updates a WebGL texture
Parameters:
-
textureTexturethe texture to update
-
glWebglContextthe WebGL context
Properties
contextLost
Boolean
Whether the context was lost
height
Number
The height of the canvas view
Default: 600
preserveDrawingBuffer
Boolean
The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering.
transparent
Boolean
Whether the render view is transparent
view
HTMLCanvasElement
The canvas element that everything is drawn to
width
Number
The width of the canvas view
Default: 800
