Next: 2.1 Observations About Primitives Up: OpenGL and X Previous: 1.2 History of OpenGL

2 OpenGL's Functionality

OpenGL is not a high-level 3D graphics interface. When you build a graphics program using OpenGL, you start with a few simple primitives. The sophistication comes from combining the primitives and using them in various modes. Figure 2 shows the available geometric primitives. Notice the ordering of the vertices, in particular for primitives such as the GL_TRIANGLE_STRIP and the GL_TRIANGLE_FAN.

To begin a primitive, the glBegin routine passes in the primitive type as an argument. Then a list of vertex coordinates are given. OpenGL has a family of routines to specify vertex coordinates. All the routines begin with the name glVertex. The suffix to a specific glVertex routine tells the type and number of coordinates for the vertex. For example, glVertex3f indicates a three coordinate vertex consisting of floating point values is to be generated.

An OpenGL primitive is completed by calling glEnd. Along with the coordinates of each vertex, per-vertex information about color, material, normals, edge drawing, and texturing can be specified between a glBegin and glEnd. Figure 3 shows an example of how a polygon might be generated. Notice how glColor3f is used to change the current color. Each vertex is drawn according to the current color.



mjk@asd.sgi.com
Wed Oct 19 18:06:42 PDT 1994