In graphics the word 'render' means the process of converting information about geometric objects into a visual image on your computer screen. Rendering a scene is a multi-step process which is often described in terms of a graphics pipeline .
At one end of the pipeline we feed in polygon vertices, color information about the objects in our scene, bitmaps to paint onto some of the scene objects or use as backgrounds, and perhaps some locations of lights. At the other end of the polygon a rendered two-dimensional color image appears in a memory location called the frame buffer . The pipeline is rudimentary in two-dimensional graphics, and is shown in Figure 24.2.
Figure 24.2. A 2D graphics pipeline
In two dimensions the Matrix Multiply step converts the controlling vertices of our polygons, rectangles, ellipses, lines, etc. into locations that may be rotated or translated away from their standard positions . The model matrix expresses the motions caused by the objects associated with the given shapes , while the view matrix expresses the way in which the viewer may have moved relative to the world. We'll say more about this in the next section.
In the Rasterization step, we convert our vertices into pixel coordinates, and use basic graphics methods to draw the corresponding polygons, rectangles, ellipses, lines. The location into which we draw these pixels is the frame buffer. If we have some bitmaps that we want to use, say as backgrounds, we copy them into the frame buffer during rasterization.
Usually the frame buffer is an offscreen memory bitmap or a RAM region on the graphics card, as it is too visually disturbing to see the drawing happening bit by bit. Once the pipeline is done filling the frame buffer, the Display Frame Buffer step makes the frame buffer image appear in a visible window. This step is sometimes done by a so-called BitBlt operation, which ( rapidly ) moves the color information pixel by pixel. When the hardware allows it, the Display Frame Buffer can be accomplished by a more rapid technique called page-flipping or buffer-swapping .
The idea behind buffer swapping is that, rather than moving the pixel information from one region of memory to another, you simply change the address that the graphics card uses as the base location from which to refresh the visual information in your window. Doing buffer swap for an onscreen window is harder than doing it for an entire screen, but newer graphics cards and graphics libraries allow this.
Now let's talk about the three-dimensional graphics pipeline. The picture is considerably more complex, as shown by Figure 24.3. We'll say more about the Matrix Multiply step in the next section.
Figure 24.3. A simplified 3D graphics pipeline
Two cases in which the Per-Vertex operations come into play are when your world has lights in it or when you plan to 'decal' or 'wallpaper' some image onto the surface of one of your three-dimensional objects. These glued-on images are called textures .
With regard to lighting, the color of a lit surface is going to vary depending on how the surface is oriented relative to the light source. With regard to texture, suppose, for instance, that you want to glue a bitmap of a circular logo onto the square wall of a house in 3D. If you look at the wall straight on, the logo appears as circle. But if you look at the wall from an angle, the bitmap image is going to have to be distorted into an elliptical shape. A texture-mapped square maintains an invisible grid of coordinates to use for pasting on the texture.
In the 2D Rasterization step, the graphics system draws directly into the frame buffer. But when rasterizing a 3D scene, the system can be thought of as drawing into an intermediate buffer called the Z-buffer . By using the Z-buffer we can automatically draw the closer shapes on top of the further shapes. Rather than drawing 'pixels,' we speak of the 3D Rasterization as drawing ' fragments .' A fragment might hold a pixel location along with information about which colors you've tried to draw there at which depths.
In the Per-Fragment operations step the system picks the closest object's pixel for each fragment. This is also the place where bitmap textures can be applied in place of (or blended with) the lighting-adjusted fill colors.
As in the two-dimensional case, the Display Frame Buffer step abruptly transfers the image to a visible location on your computer screen.