Drawing related functions

For backward compatibility they are available at both twgl.draw and twgl

See module:twgl for core functions


(static) drawBufferInfo(gl, bufferInfo, typeopt, countopt, offsetopt, instanceCountopt)

Calls gl.drawElements or gl.drawArrays, whichever is appropriate

normally you'd call gl.drawElements or gl.drawArrays yourself
but calling this means if you switch from indexed data to non-indexed
data you don't have to remember to update your draw call.

Name Type Attributes Description
gl WebGLRenderingContext

A WebGLRenderingContext

bufferInfo module:twgl.BufferInfo | module:twgl.VertexArrayInfo

A BufferInfo as returned from module:twgl.createBufferInfoFromArrays or
a VertexArrayInfo as returned from module:twgl.createVertexArrayInfo

type number <optional>

eg (gl.TRIANGLES, gl.LINES, gl.POINTS, gl.TRIANGLE_STRIP, ...). Defaults to gl.TRIANGLES

count number <optional>

An optional count. Defaults to bufferInfo.numElements

offset number <optional>

An optional offset. Defaults to 0.

instanceCount number <optional>

An optional instanceCount. if set then drawArraysInstanced or drawElementsInstanced will be called

(static) drawObjectList(gl, objectsToDraw)

Draws a list of objects

Name Type Description
gl WebGLRenderingContext

A WebGLRenderingContext

objectsToDraw Array.<DrawObject>

an array of objects to draw.