WebGLBatch Class
A WebGLBatch Enables a group of sprites to be drawn using the same settings. if a group of sprites all have the same baseTexture and blendMode then they can be grouped into a batch. All the sprites in a batch can then be drawn in one go by the GPU which is hugely efficient. ALL sprites in the webGL renderer are added to a batch even if the batch only contains one sprite. Batching is handled automatically by the webGL renderer. A good tip is: the smaller the number of batchs there are, the faster the webGL renderer will run.
Constructor
WebGLBatch
-
gl
Parameters:
-
gl
WebGLContextan instance of the webGL context
Item Index
Methods
- addDisplayObjectAndChildren
- addFilterBlocks
- clean
- growBatch
- init
- initStrip
- initTilingSprite
- insertAfter
- insertAfter
- insertBefore
- insertObject
- merge
- refresh
- remove
- removeDisplayObjectAndChildren
- removeFilterBlocks
- removeObject
- render
- render
- renderSpecial
- renderSpecific
- renderStrip
- renderTilingSprite
- restoreLostContext
- setRenderable
- split
- update
- updateTexture
Methods
addDisplayObjectAndChildren
-
displayObject
Adds a display object and children to the webgl context
Parameters:
-
displayObject
DisplayObject
addFilterBlocks
-
start
-
end
Adds filter blocks
Parameters:
-
start
FilterBlock -
end
FilterBlock
clean
()
Cleans the batch so that is can be returned to an object pool and reused
growBatch
()
Grows the size of the batch. As the elements in the batch cannot have a dynamic size this function is used to increase the size of the batch. It also creates a little extra room so that the batch does not need to be resized every time a sprite is added
init
-
sprite
inits the batch's texture and blend mode based if the supplied sprite
Parameters:
-
sprite
Spritethe first sprite to be added to the batch. Only sprites with the same base texture and blend mode will be allowed to be added to this batch
initStrip
-
strip
Initializes a strip to be rendered
Parameters:
-
strip
StripThe strip to initialize
initTilingSprite
-
sprite
Initializes a tiling sprite
Parameters:
-
sprite
TilingSpriteThe tiling sprite to initialize
insertAfter
-
item
-
displayObject
Inserts a displayObject into the linked list
Parameters:
-
item
DisplayObject -
displayObject
DisplayObjectThe object to insert
insertAfter
-
sprite
-
previousSprite
inserts a sprite after the specified sprite
insertBefore
-
sprite
-
nextSprite
inserts a sprite before the specified sprite
Parameters:
-
sprite
Spritethe sprite to be added
-
nextSprite
NextSpritethe first sprite will be inserted before this sprite
insertObject
-
displayObject
-
previousObject
-
nextObject
Inserts a displayObject into the linked list
Parameters:
-
displayObject
DisplayObject -
previousObject
DisplayObject -
nextObject
DisplayObject
merge
-
batch
Merges two batchs together
Parameters:
-
batch
WebGLBatchthe batch that will be merged
refresh
()
Refresh's all the data in the batch and sync's it with the webGL buffers
remove
-
sprite
removes a sprite from the batch
Parameters:
-
sprite
Spritethe sprite to be removed
removeDisplayObjectAndChildren
-
displayObject
Removes a display object and children to the webgl context
Parameters:
-
displayObject
DisplayObject
removeFilterBlocks
-
start
-
end
Remove filter blocks
Parameters:
-
start
FilterBlock -
end
FilterBlock
removeObject
-
displayObject
Removes a displayObject from the linked list
Parameters:
-
displayObject
DisplayObjectThe object to remove
render
()
Draws the batch to the frame buffer
render
-
projection
Renders the stage to its webgl view
Parameters:
-
projection
Object
renderSpecial
-
renderable
-
projection
Renders a specific renderable
Parameters:
-
renderable
DisplayObject -
projection
Object
renderSpecific
-
displayObject
-
projection
Renders a specific displayObject
Parameters:
-
displayObject
DisplayObject -
projection
Object
renderStrip
-
strip
-
projection
Renders a Strip
Parameters:
-
strip
StripThe strip to render
-
projection
Object
renderTilingSprite
-
sprite
-
projectionMatrix
Renders a TilingSprite
Parameters:
-
sprite
TilingSpriteThe tiling sprite to render
-
projectionMatrix
Object
restoreLostContext
-
gl
Recreates the buffers in the event of a context loss
Parameters:
-
gl
WebGLContext
setRenderable
-
displayObject
Add a display object to the webgl renderer
Parameters:
-
displayObject
DisplayObject
split
-
sprite
Splits the batch into two with the specified sprite being the start of the new batch.
Parameters:
-
sprite
Spritethe sprite that indicates where the batch should be split
Returns:
the new batch
update
()
Updates all the relevant geometry and uploads the data to the GPU
updateTexture
-
displayObject
Updates a webgl texture
Parameters:
-
displayObject
DisplayObject