DrawPrimitive

View source

Selects the WebGL primitive topology used by a draw call.

Pass one of these numeric values as the mode argument to gl.drawArrays or gl.drawElements. Points (0x0000) draws independent points; Lines (0x0001) draws independent pairs of vertices; LineLoop (0x0002) connects the vertices and closes the line; LineStrip (0x0003) connects consecutive vertices without closing the line; Triangles (0x0004) draws independent groups of three vertices; TriangleStrip (0x0005) builds connected triangles from adjacent vertices; and TriangleFan (0x0006) builds connected triangles around the first vertex.

Examples

import { DrawPrimitive } from '@wimaengine/render-webgl'

// `gl` is an existing WebGL rendering context with a bound vertex array.
gl.drawArrays(DrawPrimitive.Triangles, 0, 3)

Variants


Points

View source

Independent points; WebGL POINTS (0x0000).

Lines

View source

Independent line segments; WebGL LINES (0x0001).

LineLoop

View source

A connected line whose final vertex joins the first; WebGL LINE_LOOP (0x0002).

LineStrip

View source

A connected open line; WebGL LINE_STRIP (0x0003).

Triangles

View source

Independent triangles formed from each group of three vertices; WebGL TRIANGLES (0x0004).

TriangleStrip

View source

Connected triangles that reuse adjacent vertices; WebGL TRIANGLE_STRIP (0x0005).

TriangleFan

View source

Connected triangles that share the first vertex; WebGL TRIANGLE_FAN (0x0006).