Search Tips Advanced Search |
| Delphi Graphics and Game Programming Exposed with DirectX 7.0 by John Ayres Wordware Publishing, Inc. ISBN: 1556226373 Pub Date: 12/01/99
Search this book:
Previous | Table of Contents | Next
### Video Mode Resolutions and Color Depth Discussions of graphics programming usually start from a consideration of what resolution the video driver is currently in, and how many colors are available in which to draw the graphics. These two concepts are directly related, and are generally referred to in a combined sense as the video mode.
| video mode: The video hardware state which dictates the display resolution and number of available colors for graphical output.
These two items will have a profound effect on the graphics programming techniques involved in drawing the graphical elements previously discussed. Both the resolution and the color depth of the current video mode will affect the perceived quality of the displayed graphical images. The greater the resolution and color depth, the more realistic and detailed the displayed graphics will become. However, on the downside, higher resolution and deeper color depth mean greater memory usage and slower speed. #### Resolution The resolution of the current video mode controls how many pixels can be displayed on the screen.
| resolution: A measurement of the number of pixels displayed on the screen.
As the resolution increases, more and more pixels are available for displaying graphics. This will directly affect the perceived size of graphical images. This is especially true for raster graphics, as vector graphics can be adjusted accordingly. For example, if a bitmap image is 50 pixels by 50 pixels in size, it will appear larger when displayed at its original resolution when the video mode is set to 800 x 600 pixels than it will when the video mode is set to 1024 x 768 pixels. As illustrated in Figure 3-6, a fixed size bitmap image will appear smaller in higher resolution video modes because individual pixels must be smaller in order to fit more of them onto the screen. Figure 3-6: Two different disEplay resolutions Supported resolutions are dependent upon the video card installed in the machine, the video driver, and the monitor upon which the output is displayed. The video driver and video card dictate the video modes available for use. However, occasionally the monitor connected to the machine will be unable to handle the new video mode.
| Caution: Switching to a video mode that is unsupported by the monitor can potentially damage it, and should be avoided.
Perhaps the most common display resolution employed by desktop machines today is 800 pixels wide and 600 pixels high. However, it is usually wise to develop for the smallest common denominator in order to take advantage of a broader market (and subsequent revenue potential). Thus, many developers create games based on a 640 x 480 resolution. Generally speaking, it is harder to write code that will support a wide variety of resolution sizes. Nevertheless, the extra effort that allows users to take advantage of new equipment usually pays off, and makes your customers very happy. #### Color Depth The color depth of the current video mode controls how many colors in which an individual pixel can be drawn. Color depth is measured in bits per pixel, meaning that the more bits used to describe a color, the more colors there are available in which to draw a pixel.
| color depth: A measurement of the number of bits per pixel required to describe the color of an individual pixel.
The color depth of the current video mode will affect the techniques used to draw graphics more so than the display resolution. Color depth determines if the video mode will be palettized or non-palettized (discussed below). As this affects how pixels are stored, different techniques must be employed when drawing graphics. As the bits per pixel increase, the number of colors available for each individual pixel increases, but so does the amount of memory required to hold a bitmap. The following table summarizes common color depths and the amount of colors available per pixel under each:
Table 3-1: Color depth versus available colors
Bits Per Pixel | Number of Colors Available
--- | ---
4 8 16 24 32 | 16 colors 256 colors 65,536 colors (high color mode) 16,777,216 colors (true color mode) 16,777,216 colors plus 256 levels of transparency (true color)
Color depths of only 4 bits per pixel are no longer used for games. Perhaps the most common color depth used in games is 8 bits per pixel, as this makes it very easy to manipulate individual pixels in a bitmap, or to move large amounts of pixels around in memory. However, thanks to hardware acceleration, faster processors, and other advances, higher color depths are starting to be used in more games. 16-bit color games are becoming more prevalent, but 24-bit and 32-bit color depths are still too slow to be used for games that run on anything other than today’s higher end PCs. #### Video Board Memory Apart from the video modes supported by the video driver and the graphics card itself, available video modes are further restricted by the amount of video RAM available on the graphics card. Only video RAM can be used support various video modes, and as the resolution and color depth of a video mode increase, so does the amount of video RAM required to support it. For example, a video mode of 800 x 600 pixels at a color depth of 8 bits per pixel requires 480,000 bytes, almost half a MB. If a video mode requires more memory than is available on the video card, it cannot be supported. For example, a video mode of 1024 x 760 at 16 bits per pixel cannot be supported unless the video card has at least 1,572,864 bytes of RAM available. This will become much more important later when we discuss DirectX surfaces. #### The Components of a Color When discussing pixel colors and color depth, it is important to understand how colors are represented internally. The color of every pixel drawn to the screen is determined by three components: a red intensity, a blue intensity, and a green intensity. As these intensities increase or decrease, the color of an individual pixel is affected accordingly. Each intensity can have a minimum value of 0, and a maximum value of 255. If the intensity of each component is 0, the resulting color is black, while if each component is at 255, the resulting color is white. This gives a maximum of 16,777,216 colors, well beyond the scope of what the human eye can accurately detect from shade to shade. This is referred to as RGB color, standing for red, green, and blue, respectively.
| RGB color: Refers to the method by which colors are represented, usually in the form of a red, green, and blue component, respectively.
Most of the time, colors are used in this RGB format. However, occasionally colors will be used in a reverse format (BGR), depending on which GDI functions are being used.
Previous | Table of Contents | Next

Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.