Graphics Reference
In-Depth Information
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, CubeVertices );
glColorPointer( 3, GL_FLOAT, 0, CubeColors );
glDrawElements( GL_QUADS, 24, GL_UNSIGNED_INT, CubeIndices );
which is certainly shorter and feels somewhat more elegant.
Notice that the CubeIndices array is never named by a pointer-
specifying function; it is simply an ordinary array of indices.
The result is shown in Figure 1.12.
This is a very simple example, but in applications it is not
uncommon to have these arrays contain hundreds, if not thou-
sands, of vertices, and to have large portions of scenes cap-
tured in single arrays. This is sound data encapsulation and
re-use, and it makes scenes much faster to render.
Vertex arrays are stored on the client, or host, side of the
bus. That means that they are not as efficiently accessible to the
graphics card as they could be. Vertex buffer objects (VBOs),
which operate just like vertex arrays but live on the graphics
card side, are a more efficient way to encapsulate graphics
geometry. VBOs are created and used almost identically to vertex arrays, with
a few small differences. See the OpenGL “Red Book” [41] for details.
Figure 1.12. The RGB cube
produced by the code above
(with axes added).
Conclusions
The fixed-function graphics pipeline has shown itself to be very valuable in
creating a model for computer graphics that has become widely used. It can be
implemented in both software and hardware with predictable results across
all computing platforms. Its fully determined processing lets most graphics
operations be optimized and moved into silicon. These well-designed data
paths let graphics use parallel processing to handle vertex data uniformly, and
the parallel architecture of graphics cards lets the rendering processor handle
many pixels simultaneously. The number of vertex and fragment processors
on a card is continually growing, and as of this writing has reached as high
as 128. This speeds fragment processing significantly.
As we go through the traditional fixed-function pipeline, however, we
see that there are some kinds of graphics operations we would like to do that
are simply hard to handle. All of these have been done in specially built com-
puter graphics systems, often in research environments, and it is a goal of the
Search WWH ::




Custom Search