next up previous contents index
Next: 2.8 Vertex Arrays Up: 2 OpenGL Operation Previous: 2.6.3 GL Commands within

2.7 Vertex Specification


Vertices are specified by giving their coordinates in two, three, or four dimensions. This is done using one of several versions of the Vertex  command:

void Vertex[234][sifd] ( T coords ) ;
void Vertex[234][sifd]v ( T coords ) ;

A call to any Vertex  command specifies four coordinates: x, y, z, and w. The x coordinate is the first coordinate, y is second, z is third, and w is fourth. A call to Vertex2  sets the x and y coordinates; the z coordinate is implicitly set to zero and the w coordinate to one. Vertex3  sets x, y, and z to the provided values and w to one. Vertex4  sets all four coordinates, allowing the specification of an arbitrary point in projective three-space. Invoking a Vertex  command outside of a Begin / End  pair results in undefined behavior.

Current values are used in associating auxiliary data with a vertex as described in section 2.6. A current value may be changed at any time by issuing an appropriate command. The commands

void TexCoord[1234][sifd] ( T coords ) ;
void TexCoord[1234][sifd]v ( T coords ) ;

specify the current homogeneous texture coordinates, named s, t, r, and q. The TexCoord1  family of commands set the s coordinate to the provided single argument while setting t and r to 0 and q to 1. Similarly, TexCoord2  sets s and t to the specified values, r to 0 and q to 1; TexCoord3  sets s, t, and r, with q set to 1, and TexCoord4  sets all four texture coordinates.

The current normal is set using

void Normal3[bsifd] ( T coords ) ;
void Normal3[bsifd]v ( T coords ) ;

The current normal is set to the given coordinates whenever one of these commands is issued. Byte, short, or integer values passed to Normal  are converted to floating-point values as indicated for the corresponding (signed) type in Table 2.6.

Finally, there are several ways to set the current color. The GL stores both a current single-valued color index, and a current four-valued RGBA color. One or the other of these is significant depending as the GL is in color index mode or RGBA mode. The mode selection is made when the GL is initialized.

The command to set RGBA colors is

void Color[34][bsifd ( T components ) ;
void Color[34][bsifd ( T components ) ;

The Color  command has two major variants: Color3  and Color4 . The four value versions set all four values. The three value versions set R, G, and B to the provided values; A is set to 1.0. (The conversion of integer color components (R, G, B, and A) to floating-point values is discussed in section 2.13.)

Versions of the Color  command that take floating-point values accept values nominally between 0.0 and 1.0. 0.0 corresponds to the minimum while 1.0 corresponds to the maximum (machine dependent) value that a component may take on in the framebuffer (see section 2.13 on colors and coloring). Values outside are not clamped.

The command

void Index[sifd ( T index ) ;
void Index[sifd ( T index ) ;

Index  updates the current (single-valued) color index. It takes one argument, the value to which the current color index should be set. Values outside the (machine-dependent) representable range of color indices are not clamped.

The state required to support vertex specification consists of four floating-point numbers to store the current texture coordinates s, t, r, and q, three floating-point numbers to store the three coordinates of the current normal, four floating-point values to store the current RGBA color, and one floating-point value to store the current color index. There is no notion of a current vertex, so no state is devoted to vertex coordinates. The initial values of s, t, and r of the current texture coordinates are zero; the initial value of q is one. The initial current normal has coordinates . The initial RGBA color is . The initial color index is 1.

next up previous contents index
Next: 2.8 Vertex Arrays Up: 2 OpenGL Operation Previous: 2.6.3 GL Commands within

David Blythe
Sat Mar 29 02:23:21 PST 1997