Drawing Functions
The drawArrays and drawElements functions are used for writing to the framebuffer. drawArrays uses vertex data in the order in which it is defined in the buffer to create the geometry. In contrast, drawElements uses indices to access the vertex data buffers and create the geometry. Both drawArrays and drawElements will only use enabled arrays. These are the vertex buffer objects that are mapped to active vertex shader attributes.
In our example, the buffer that contains the vertex coordinates is the only enabled array. However, in a more general scenario, there may be several enabled arrays at our disposal.
For instance, we can have arrays with information about vertex colors, vertex normals, texture coordinates, and any other per-vertex data required by the application. In this case, each one of them would be mapped to an active vertex shader attribute.
In Chapter 3, Lights, we will learn how to use a vertex normal buffer and vertex coordinates to create a lighting model for our geometry. In that scenario, we will have two active arrays: vertex coordinates and vertex normals.