Game Programming
VGA Display Principles

Overview

Displaying pixels on a VGA display monitor is roughly the same as displaying a standard TV screen from a broadcast station. It works much the same way.

A small, narrow beam of electrons are propelled from a "gun" at the back of the CRT towards the front face where a phosphor-based material is uniformly deposited. The electrons are released from a small filament of specially coated wire that is heated to help force the electrons out of the wire and into the vacuum around it. They are then propelled away from the wire and towards the screen by a high positive voltage on back side of the CRT face.

If that's all there was, the electrons would simply stream helter-skelter to the CRT face and there would only be a general glow of light and no detailed image. However, there are some steering elements to help guide the electrons into a narrow beam as well as electron absorbers to pick up and remove electrons that aren't well focused. By focusing some of the electrons and removing the hard-to-focus remainder, a narrow beam results. By twiddling with the steering voltages a bit, you can cause this narrow beam to move about the front screen face kind of like an etch-a-sketch.

Now, color makes this just a bit more complicated. It's rather easy to come up with various phosphor compounds that exhibit different colors when they are struck by electrons. But once they are mixed, their color doesn't really change much. So to get a color screen three different color mixes are used, placing three tiny dots of different phosphors on the CRT face in each small "pixel" area. By carefully arranging them close together and in a fixed relationship to each other so the electronics can pick out one from another, a human will not see them as separate dots, but as a combined color. This effect is enhanced by including a very black mask that fills in the space between these color triads. They are colored red, green, and blue. The color that your eye senses will be a complicated formulation of the combined wavelengths and their relative intensities.

Image Details

A display monitor is operated to display an image by starting the beam near the upper-lefthand corner of the screen and then to sweep it exactly horizontally from the left side to the right, while modulating (varying) the beam strength and position to light up the phosphor color dots as it moves past them. It takes a little while to move the beam from one area to another, so hitting all of the pixels in a line like this is efficient. Trying to pick them out at random would mean all kinds of longer delays and each screen full would take much longer, overall.

However, the beam does need to be turned as close to off as possible when swinging it back to the left side of the screen to start on the next line. I don't know the history as to why they didn't just choose to sweep the next line backwards, but they just didn't design it that way. So, this period of time required to swing the beam back to the left side (by modifying the voltages on the beam steering elements) while keeping the beam off is called the horizontal retrace period. Since the beam isn't on and doesn't need to hit all the color dots on the way back, it can be swung back into position much faster.

Actually, to bring the beam back to the left side of the screen, there are two steps. The first step is to simply turn off the beam so that more pixels can't be accidentally lit up. Then the voltages on the steering elements are changed to start the return swing. Once the beam has returned to the left side, the monitor will start scanning it back in a rightward motion from the far left edge to the visible left edge of the display, all the while still keeping the beam "blanked." Once the beam has arrived at the visible left edge, it is turned on again for the next display line.

So a horizontal line starts out at the left visible edge of the screen, hitting each of the 3 color dots of a pixel with separate intensity values for each color, advances to the next pixel and repeats this until the right visible edge is reached. Then it starts the horizontal blanking while preparing for the return swing to the left and begins the horizontal retrace or swing back to some distance beyond the left visible edge. Once it gets back past the left edge, it prepares for and begins to start sweeping back to the right, thus ending the horizontal retrace period, but not the horizontal blanking period until it reaches the left visible edge, when the next scan line begins once again.

This line-by-line process continues until the entire image has been scanned onto the CRT face. Once the entire image is complete, the phosphor dots up near the top are already beginning to fade out from last time, so the whole process is repeated once again by going back up to the upper lefthand corner to start anew. Just like the horizontal display method, there is a vertical blanking interval during which the vertical retrace period occurs while the beam is brought back up to the top left corner from the bottom right corner. Once the beam swings back into position on the first line, the new image can start again.

TV sets use a method like this, called NTSC, which actually scans the odd numbered horizontal lines first, then goes back and scans the even ones. This is called "interlacing." Computer display monitors will use this technique, too, when their speed just can't keep up with the pixels if all the lines are scanned the first time. You can usually see this as a kind of annoying flickering of the display, since the phosphor often manages to dim down more by the time the beam gets back to restoring the image.

Summary

So that's the process that is used to fill out a display on the screen. If you think a bit about it, you can see that changing the point at which you start the horizontal retrace within the horizontal blanking period, you can adjust where the left edge of the screen is at on the monitor. The same is also true for the vertical timing signals in aligning the top and bottom margins.

It's a pretty basic idea, but managing all of the little details in exactly the right way is what makes the difference between success and failure.

Quick links:
 
   
 
    Creation Date:  Mon 29-Mar-1999 15:20:43
    Last Modified:  Sun 09-Apr-2000 20:55:03
    Copyright (C) 1999, 2000 Jonathan Dale Kirwan