• Aucun résultat trouvé

Hardware Basics

Dans le document Computer Graphics and Geometric Modeling (Page 23-26)

Although the goal of this book is to emphasize the abstract ideas in graphics, one does need to understand a few hardware basics because that is what drives the search for efficient algorithms for the implementation of low-level graphics primitives. The most common display devices have been cathode ray tube (CRT) devices. Here an electron beam traces out an image on a phosphor-coated screen. There have been different types of CRTs, but since the early 1970s raster scan CRTs have been the most preva-lent graphics display devices. They are refresh CRTs because the electron beam is con-tinually rescanning the entire screen. The screen itself should be thought of as a rectangular array of dots. The image that one sees depends on how those dots are lit.

The beam starts at the top of the screen and proceeds down the screen from one scan lineto the next until it gets to the bottom. It then jumps back to the top. See Figure 1.7. The term “horizontal retrace” refers to the time the beam jumps from the end of a line to the beginning of the next line and “vertical retrace” refers to the time it jumps from the right bottom corner of the screen to the top left corner. These times, espe-cially the latter, were often used to write to the screen to avoid flicker and knowing them was important to game developers who wanted to produce smooth animation effects.

Another display technology that has been becoming more and more popular in recent years is the liquid crystal display(LCD). Although there are different variants, LCDs are also raster scan devices because, for all practical purposes, they consist of a rectangular array of dots that is refreshed one row at a time. The dots themselves are the “liquid crystals,” which are usually organic compounds that consist of mole-cules that allow light to pass through them if they are aligned properly by means of an applied voltage. The bottom line is that the liquid crystals can be individually switched on or off. LCDs have a number of advantages over the raster scan CRTs. In Figure 1.5. 2d graphics coordinate system and

window.

Æ

Æ Æ Æ

clip against window

transform to viewport

transform to physical device coordinates representation

of 2d world objects

Figure 1.6. The basic 2d graphics pipeline.

particular, one does not have to worry about refresh rates or flicker and they are not as bulky.

The hardware assumption made in this book, one that should apply to two-dimen-sional displays in the foreseeable future, is that the reader is working on a raster scan device. This assumption has an important consequence. Raster scan devices use a refresh buffer to specify which dots on the screen are to be lit and how. To get the picture we want, we only have to set the values in that buffer correctly. Therefore, our abstract representation problem specializes to representing subsets of Euclidean space as (discrete) subsets of a rectangle in Z2. Less formally, we shall talk about rep-resenting objects in a “raster.” A rasterrefers to a two-dimensional rectangular array of pixels, where a pixelis an abbreviation for “picture element,” which could, in theory, be any value. In practice, a pixel is represented in computer memory by one or more bits that specify a color. A monochrome picture is where each pixel is represented by only one bit. A row in a raster is called a scan line. If the raster has m columns and n rows, then we say that the resolutionof the picture is m ¥n.

The hardware graphics standards for computers have evolved over time. The stan-dards for the IBM personal computer (PC) are listed in chronological order below:

Figure 1.7. The raster scan CRT.

Type Resolution Number of colors

CGA 640 ¥200 2 (black plus one other)

Hercules 720 ¥348 2 (black and white)

EGA 640 ¥350 16

VGA 640 ¥480 16

super VGA ≥800¥600 ≥256

For more details about these standards see [Wilt87] or [Ferr94].

The refresh buffer of a raster scan device is usually called a frame buffer. In general, the term “frame buffer” refers to an array of memory (separate from main memory) thought of as a two-dimensional array of pixels (a raster). Frame buffers serve two functions:

(1) as a place where the image is stored as it is computed

(2) as a refresh buffer from which the image is displayed on a raster device

A frame buffer is an interface between what are usually relatively slow graphics compu-tations and the high data rate video image display. In the typical personal computer the frame buffer is located on the graphics card that manages the video subsystem of the computer. It basically used to be not much more than some extra memory. For example, the table below describes the frame buffers used by the IBM PC family of computers:

Type Size of frame buffer Starting memory address (in hexadecimal)

CGA 16 K B800:0000

Hercules 64 K B000:0000

EGA,VGA 256 K for 16 colors accessed via a 64 K window starting at A000:0000 super VGA 1 M or more accessed via a 64 K window starting at A000:0000

Over time the graphics subsystems of personal computers have become more power-ful, and the hardware is supporting more and more of the operations that one needs to perform in graphics, such as antialiasing (Section 2.6) and the bit map operations discussed below and in Section 2.10. They also have additional buffers, such as a z-buffer (Chapter 7), texture z-buffers (Chapter 9), or stencil z-buffers (for masking opera-tions). This support only used to be found on high-end graphics workstations.

As indicated above, displaying objects on the computer screen involves writing to the frame buffer. This amounts to storing values in memory. Ordinarily, a store opera-tion replaces the value that was there. In the case of frame buffers one has more options. If A is a location in memory, then let [A] denote the content of A. Frame buffers typically support store operations of the form (V op[A])Æ[A], where V is a new value andopis a binary logical operator that operates on a bit-by-bit basis. Typical binary logical operations on bits are or,and,xor, and replace. The statement (V replace[A]) Æ[A] corresponds to the standard store operation where the new value replaces the old one. When a frame buffer uses a store operation corresponding to an operator op, we shall say that it is in opmode. For example, we may talk about being in xormode.

As a simple example of how having various modes for a frame buffer can be useful, consider how the standard quick and dirty method used to move a cursor around on the screen without destroying the background uses the xormode. The method relies onxor’s well-known property that

What this means is that if one xor’s the same value to a memory location twice in a row, then that memory location will hold its original value at the end. Now, a straight-forward way to move a cursor on the screen without erasing what is there would be to save the area first before writing the cursor to it and then restoring the old value after the cursor has moved. This would be very time consuming. There is a much better way of using the xor mode. Assume that the cursor starts out at some initial position defined by a variable oldA. Now switch into xor mode and repeat the fol-lowing three steps as often as desired:

Draw cursor at oldA (this will erase the cursor) Draw cursor at new position newA

Replace the value in oldA with that in newA bxor(bxora)=a.

Note that replace mode would cause this loop to erase everything in the cursor’s path and leave behind a trail of the cursor. There is one disadvantage with thexor operation, however, which may not make it a viable option in certain situa-tions. Although one can use it to move objects around on the screen without destroy-ing the background, the objects may change color. If, for example, one wants to move a red cursor and have it stay red, then this is not possible with xor mode because the cursor will assume different colors as it moves over differently colored areas of the screen. Therefore, if it is important that the cursor stay red, then there is no simple alternative to first saving the area to which one is writing and restoring it afterwards.

Because the availability of logical operators in store operations simplifies and speeds up many useful graphics operations, current graphics systems have built-in hardware support for them. We will have more to say about this in Section 2.10.

We finish this section with two more terms one sees frequently in graphics. Scan conversion is the act of converting points, lines, other geometric figures, functions, etc., into the raster data structure used in frame buffers one scan line at a time. After a scene is modeled, it needs to be “rendered.” To render a scene means to construct an image on a display device that is visually satisfactory. What is “satisfactory”

depends firstly on the device and its constraints and secondly on what one is trying to do. To emphasize the position that rendering occupies in graphics, keep in mind that the modeling or mathematical representation comes first and then the rendering.

Any given model can have many different renderings. For example, a sphere can be rendered in different colors. In trying to render scenes one runs into a number of important problems: visible line or surface determination, illumination, texturing, transparency, etc. These will all be addressed in coming chapters.

Dans le document Computer Graphics and Geometric Modeling (Page 23-26)