The vertex array is almost same as the commands between
glBegin/glEnd, only the map itself executes them, substituting the values from our array. We necessary to describe not only the vertices, but also the normals, texture coordinates, color, and so arrays are different. However, we will not torment ourselves by connecting all arrays, we just throw everything into the heap with the
glInterleavedArrays function (that is, the data in the array goes sequentially, first the normal of one vertex, then its texture coordinates, color, etc. then the vertex coordinates themselves. Then, too most for the next peak, etc.) It takes parameters as the type of “piled up” arrays, here it is
GL_N3F_V3F, that is,
N3F is an array of normals, 3 floats per normal and
V3F an array of vertices, also of 3 floats per vertex, the so-called “stride” - distance "between the data for the neighboring vertex (we will have" 0 "since the data in the array goes in a row), and finally, a link to the data array (
textureBlank). But
glInterleavedArrays only connects arrays to display, they still need to be mapped. This is done with the
glDrawArrays function.
- The first parameter is the type of primitives used (GL_TRIANGLES)
- the second is the first element of the array (= 0, that is, we draw all the elements)
- and the third parameter is the total number of elements
A rewrited example varrays.asm from the "FASM OpenGL tutorial from Tyler Durden". There are asm-file, bin-file, cursor and exe-file in the attachment.