Graphics Reference
In-Depth Information
Vertex Arrays
Throughout this chapter, in order to keep the concepts clear, we have been
talking about the graphics pipeline as it operates on simple vertices and
primitives. In actual applications, however, there are techniques that greatly
increase the speed of graphics processing. One such technique is called vertex
arrays . You may have already met this in an earlier computer graphics course,
but if you have not, we want to give you a quick look at it here.
Vertex arrays are created on the host CPU to store vertex coordinates
and vertex atributes. These arrays are transmited to the graphics card along
with indices that tell what vertex numbers need to be connected in graphics
primitives. This way, each vertex is only transformed once, and there are fewer
overall function calls.
Vertex arrays are activated with the command
glEnableClientState( type )
where type includes
GL_VERTEX_ARRAY
GL_COLOR_ARRAY
GL_NORMAL_ARRAY
GL_SECONDARY_COLOR_ARRAY
GL_TEXTURE_COORD_ARRAY
This function lets you enable all the vertex arrays you need to describe vertex
data.
To deactivate a vertex type, use
glDisableClientState( type )
Once you have activated the vertex state(s) you need, you can fill the
arrays by simple array operations, such as these for vertex data:
static GLfloat Vertices[ ][3] = {
{
{ 1., 2., 3. },
{ 4., 5., 6. },
. . .
};
Similar operations could fill arrays for colors, normals, and texture coor-
dinates, as noted above. To specify that an array will be used as a vertex array,
you use the functions
Search WWH ::




Custom Search