For this exercise, a buffer and shader has been prepared for you and all attribute values have been set. You should use the draw arrays command to draw the following primitives in this order:
- A line loop with 32 vertices starting at vertex 99
- A triangle fan with 5 vertices starting at vertex 131
- 32 lines starting from vertex 35
- 32 points starting from vertex 3
- A single triangle starting from vertex 0
Once we have a buffer and shader set up, along with all the associated attribute pointers, we can finally start drawing stuff. This is done using the gl.drawArrays command. Here is an example of what a call to drawArrays looks like:
gl.drawArrays(gl.TRIANGLES, 0, 12)The interface for this function is as follows:
typeis the type of primitive to drawoffsetis the starting vertex to draw fromcountis the number of vertices to draw
The possible values for type are as follows:
gl.TRIANGLESdraws a list of triangles. Note thatcountmust be a multiple of 3 for this to workgl.LINESdraws a list of line segments.countmust be a multiple of2gl.POINTSdraws a list of points.gl.LINE_STRIPdraws a connected polyline between each subsequent vertexgl.LINE_LOOPlikegl.LINE_STRIP, except the first and last vertices are connectedgl.TRIANGLE_FANkeeping the first vertex fixed, draws a triangle for each subsequent edge in the sequence of verticesgl.TRIANGLE_STRIPdraws a triangle for every 3 consecutive vertices in the list