Chapter 2. Drawing Primitives


Computer-generated animation in film and television, as well as state-of-the-art video games, features realistic water, fire, and other natural effects. Many people new to computer graphics are astounded to learn that these realistic and complex models are simple triangles and pixels as far as computer graphics hardware is concerned.

OpenGL is often referred to as a low-level API because of its minimal support for higher-order primitives, data structures such as scene graphs, or support for loading 2D image files or 3D model files. Instead, OpenGL focuses on rendering low-level primitives efficiently and with a variety of basic, yet flexible, rendering features. As a result of this "tools not rules" approach, OpenGL is the preferred low-level API for a variety of middle-ware and applications that feature higher-order primitives, scene graph data structures, and file loaders.

In this chapter, OpenGL® Distilled covers the OpenGL primitive types and how to control their appearance with several basic rendering features.

What You'll Learn

This chapter covers the following aspects of primitive rendering:

  • Primitive typesThe ten primitive types for rendering point, line, and polygonal primitives.

  • Buffer objects and vertex arraysGenerally recognized as the most efficient method for specifying geometry.

  • Rendering detailsOpenGL commands for hidden surface removal, transparency, and displaying co-planar primitives.

  • Performance issuesSome tips to help your application run as efficiently as possible on most OpenGL implementations.

What You Won't Learn

Because this book presents only OpenGL's most essential commands, several aspects of primitive rendering aren't covered in this chapter:

  • The glBegin()/glEnd() paradigmOpenGL® Distilled covers the glBegin()/glEnd() paradigm for illustrative purposes only. Most OpenGL implementations avoid using glBegin()/glEnd() to specify geometry due to its inherent performance issues.

  • Vertex dataThis chapter covers normal and texture-coordinate data and omits other vertex data, such as vertex attributes (used in vertex shaders), edge flags, and fog coordinates.

  • Mapping and unmapping buffer objectsThis chapter doesn't discuss the interface for dynamically altering portions of buffer object data.

  • EvaluatorsOpenGL allows programmers to render implicit curves and surfaces from control points.

  • RectanglesBecause you can specify vertices to render any desired shape, this shorthand interface for drawing rectangles in the z=0z=0 plane is rarely used.

  • Full vertex array functionalityThis book presents a subset of the vertex array interface and doesn't cover interleaved arrays; vertex array data types other than GL_FLOAT and GL_DOUBLE; and some vertex array rendering commands, such as glDrawArrays().

  • This book doesn't cover all features that affect the final color and appearance of rendered geometry, such as fog, stencil, vertex and fragment shaders, and other related features.

Though useful in many rendering circumstances, these features aren't essential for OpenGL programming. If your application requires this functionality, see OpenGL® Programming Guide, OpenGL® Reference Manual, and OpenGL® Shading Language.




OpenGL Distilled
OpenGL Distilled
ISBN: 0321336798
EAN: 2147483647
Year: 2007
Pages: 123
Authors: Paul Martz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net