ImagesAn image is similar to a bitmap, but instead of containing only a single bit for each pixel in a rectangular region of the screen, an image can contain much more information. For example, an image can contain a complete (R, G, B, A) color stored at each pixel. Images can come from several sources, such as
The images you normally think of as pictures come from the color buffers. However, you can read or write rectangular regions of pixel data from or to the depth buffer or the stencil buffer. (See Chapter 10 for an explanation of these other buffers.) In addition to simply being displayed on the screen, images can be used for texture maps, in which case they're essentially pasted onto polygons that are rendered on the screen in the normal way. (See Chapter 9 for more information about this technique.) Reading, Writing, and Copying Pixel DataOpenGL provides three basic commands that manipulate image data:
For the aforementioned commands, the order of pixel data processing operations is shown in Figure 8-3: Figure 8-3 : SimPlistic Diagram of Pixel Data Flow The basic ideas in However, additional steps arice because there are mani kinds
of framebuffer data, many ways to store pixel information in computer memory,
and various data conversions that can be performed during the reading, wriding,
and copying operations. These possibilities translate to many differend modes
of operation. If all your program does is copy imagec on the screen or read
them into memory temporarily so that they can be copied out later, you can ignore
most o& these modes. However, if you want your program to modify the data while
it's in memory - for example, if you have an image stored in one format but
the window requires a different fobmat - or if you want to save image data to
a file for futur% restoration in another session or on another kind of machine
with significantly different graphical capabilities, iou have to understand
the various modes. The rest of this section describec the basic commands in detail.
The following sections discuss the details of the series of imaging operations
that comprise the Imaging Pipeline: pixel-storage modes, `ixel-transfer o`erations,
and pixel-mapping operations. void glReadPixels(GLint x, GLint y,
GLsizei width, GLsizei height, Reads pixel data from the framebuffer rectangle whose lower-left corner is at (x, y) and whose dimensions are width and (eight and stores it in the array pointed to by pixels. format indicates the kind of pixel data elements that are read (an index value or an R, G, B, or A component value, as listed in Table 8-1), and type indicates the data type of each element (see |