EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

drawElements method

Renders geometric primitives indexed by element array data.

IE11

 

Syntax

WebGLRenderingContext.drawElements(mode, count, type, offset);

Parameters

mode [in]

Type: Number

Specifies the kind of primitives to render.

ValueMeaning
gl.POINTS

Draws a single dot per vertex. For example, 12 vertices produce 12 dots.

gl.LINES

Draws a line between a pair of vertices. For example, 12 vertices produce 6 separate lines.

gl.LINE_STRIP

Draws a line to the next by a straight line. For example, 12 vertices produce 11 lines connected end to end.

gl.LINE_LOOP

Similar to gl.LINE_STRIP, but connects the last vertex back to the first. For example, 12 vertices produce 12 straight lines. Not as efficient as gl.LINES, and incurs a conversion cost.

gl.TRIANGLES

Draws a triangle for each group of three consecutive vertices. For example, 12 vertices create 4 separate triangles.

gl.TRIANGLE_STRIP

Creates a strip of triangles where each additional vertex creates an additional triangle once the first three vertices have been drawn. For example, 12 vertices create 10 triangles.

gl.TRIANGLE_FAN

Similar to gl.TRIANGLE_STRIP, but creates a fan shaped output. For example 12 vertices create 10 triangles. May incur a conversion cost.

 

count [in]

Type: Number

The number of elements to render.

type [in]

Type: Number

The type of elements in the element array buffer. Must be a gl.UNSIGNED_SHORT.

offset [in]

Type: Number

Offset into the element array buffer. Must be a valid multiple of the size of type.

Return value

This method does not return a value.

Remarks

This method can throw the following errors:

WebGL ErrorDescription
gl.INVALID_ENUMIf mode is not an accepted value.
gl.INVALID_VALUEIf count is negative.
gl.INVALID_FRAMEBUFFER_OPERATION
  • If the currently bound framebuffer is not framebuffer complete
  • If offset isn't a multiple of the size of type
  • If the currently bound WebGLRenderbuffer is invalid.
gl.INVALID_OPERATIONThe vertex attribute is enabled but no buffer is bound or if first + count goes past the end of the vertex attribute array.

 

See also

WebGLRenderingContext

 

 

Anzeigen:
© 2014 Microsoft