Shaku

Shaku JS

Back To Table of Content

Draw Batch

DrawBatch

Base class for a drawing batch, used to draw a collection of sprites or shapes.

Kind: global class

new DrawBatch()

Create the draw batch.

drawBatch.defaultEffect ⇒ Effect

Get the default effect to use for this drawing batch type.

Kind: instance property of DrawBatch
Returns: Effect - Default effect to use for this drawing batch.

drawBatch.BuffersUsage

Get the BuffersUsage enum.

Kind: instance property of DrawBatch
See: BuffersUsage

drawBatch.isDestroyed ⇒ Boolean

Return if the batch was destroyed.

Kind: instance property of DrawBatch
Returns: Boolean - True if batch was destoryed.

drawBatch.isDrawing ⇒ Boolean

Return if the batch is currently drawing.

Kind: instance property of DrawBatch
Returns: Boolean - If the batch began drawing.

drawBatch.isStatic ⇒ Boolean

Return if this batch was turned static.

Kind: instance property of DrawBatch
Returns: Boolean - True if its a static batch you can no longer change.

drawBatch.defaultBlendMode

Get the default blend mode to use for this drawing batch.

Kind: instance property of DrawBatch

drawBatch.makeStatic()

Make the batch buffers static. This means you won’t be able to change the drawings in this batch once end() is called, but you’ll be able to redraw the batch with different effects and transformations without copying any data, and much faster. This also free up some internal arrays, thus reducing the memory used for this batch. Note: must be called after ‘begin()’ and right before the ‘end()’ call.

Kind: instance method of DrawBatch

drawBatch.destroy()

Destroy the batch and free any resources assigned to it.

Kind: instance method of DrawBatch

drawBatch.setBuffersUsage(usage)

Set the way we mark the buffers we pass to the GPU based on expected behavior. Use StreamDraw if you want to set buffers once, and use them in GPU few times. Use DynamicDraw if you want to set buffers many times, and use them in GPU many times. Use StaticDraw if you want to set buffers once, and use them in GPU many times.

Kind: instance method of DrawBatch

Param Type Description
usage BuffersUsage Buffers usage.

drawBatch.begin([blendMode], [effect], [transform], [overrideEffectFlags])

Start drawing this batch. You must call this before doing any draw calls.

Kind: instance method of DrawBatch

Param Type Description
[blendMode] BlendModes Blend mode to draw this batch in.
[effect] Effect Effect to use. If not defined will use this batch type default effect.
[transform] Matrix Optional transformations to apply on all sprites.
[overrideEffectFlags] \* Optional flags to override effect’s defaults. Possible keys: {enableDepthTest, enableFaceCulling, enableStencilTest, enableDithering}.

drawBatch.endWithoutDraw()

Finish drawing without presenting on screen.

Kind: instance method of DrawBatch

drawBatch.end()

End drawing and present whatever left in buffers on screen.

Kind: instance method of DrawBatch

drawBatch.present()

Draw whatever is currently in buffers without ending the draw batch.

Kind: instance method of DrawBatch

drawBatch.clear()

Clear this buffer from any drawings in it. Called internally if ‘preserveBuffers’ is not true.

Kind: instance method of DrawBatch