Perhaps the most common problem encountered by programmers who are new to OpenGL is the blank screen; executing an OpenGL program produces an empty window rather than a rendered image. Although several application problems can cause this result, the most common cause is misconfiguring the OpenGL transformation pipeline. To avoid blank screens, you need to be adept at controlling the OpenGL transformation state. OpenGL provides a powerful, flexible set of routines for controlling transformation and viewing. This programming interface isn't always straight-forward, however, especially if it's been a few years since you opened a linear-algebra textbook. OpenGL doesn't provide a "place the camera here" command, for example. To specify a view location and orientation, OpenGL requires the application to compute the inverse of the camera transformation matrix. (Fortunately, GLU somewhat addresses this with gluLookAt(), discussed in this chapter.) Another common source of confusion is the difference between the view transformation, which positions and orients the camera, and the projection transformation, which determines the field of view, the shape of the view volume, and the projection type (parallel or perspective). Confusing these transformations can cause problems not only with viewing, but also with other OpenGL features, such as lighting and clipping. This chapter covers the essentials of OpenGL transformation and viewing, and points out areas that are confusing to some programmers. What You'll LearnThis chapter covers the following topics:
What You Won't LearnThe following aspects of the OpenGL transformation system are not covered in this chapter:
If you need to review linear algebra as applied to the field of computer graphics, see Chapter 5, "Geometrical Transformations," and the appendix, "Mathematics for Computer Graphics," in Computer Graphics: Principles and Practice. |