1.4. 桢缓存 The Frame Buffer
OpenGL is an API for drawing graphics, and so the fundamental purpose for OpenGL is to
transform data provided by an application into something that is visible on the display screen.
This processing is often referred to as RENDERING. Typically, this processing is accelerated by
specially designed hardware, but some or all operations of the OpenGL pipeline can be
performed by a software implementation running on the CPU. It is transparent to the user of
the OpenGL implementation how this division among the software and hardware is handled. The
important thing is that the results of rendering conform to the results defined by the OpenGL
specification.
The hardware that is dedicated to drawing graphics and maintaining the contents of the display
screen is often called the GRAPHICS ACCELERATOR. Graphics accelerators typically have a region of
memory that is dedicated to maintaining the contents of the display. Every visible picture
element (pixel) of the display is represented by one or more bytes of memory on the graphics
accelerator. A grayscale display might have a byte of memory to represent the gray level at
each pixel. A color display might have a byte of memory for each of red, green, and blue in
order to represent the color value for each pixel. This so-called DISPLAY MEMORY is scanned
(refreshed) a certain number of times per second in order to maintain a flicker-free
representation on the display. Graphics accelerators also typically have a region of memory
called OFFSCREEN MEMORY that is not displayable and is used to store things that aren't visible.
OpenGL assumes that allocation of display memory and offscreen memory is handled by the
window system. The window system decides which portions of memory may be accessed by
OpenGL and how these portions are structured. In each environment in which OpenGL is
supported, a small set of function calls tie OpenGL into that particular environment. In the
Microsoft Windows environment, this set of routines is called WGL (pronounced "wiggle"). In the
X Window System environment, this set of routines is called GLX. In the Macintosh
environment, this set of routines is called AGL. In each environment, this set of calls supports
such things as allocating and deallocating regions of graphics memory, allocating and
deallocating data structures called GRAPHICS CONTEXTS that maintain OpenGL state, selecting the
current graphics context, selecting the region of graphics memory in which to draw, and
synchronizing commands between OpenGL and the window system.
The region of graphics memory that is modified as a result of OpenGL rendering is called the
FRAME BUFFER. In a windowing system, the OpenGL notion of a frame buffer corresponds to a
window. Facilities in window-system-specific OpenGL routines let users select the frame buffer
characteristics for the window. The windowing system typically also clarifies how the OpenGL
frame buffer behaves when windows overlap. In a nonwindowed system, the OpenGL frame
buffer corresponds to the entire display.
A window that supports OpenGL rendering (i.e., a frame buffer) may consist of some
combination of the following: