This is quite difficult to do well but there are a couple of examples. The main difficulty is in the speed of the CPU.
Here's one doing direct VGA output: Make: Arduino VGA Demo
If you Google "Arduino VGA" there are a few demo projects.
A couple options are the "TellyMate" shield that lets you output Composite rather than VGA (the single yellow connector you find on your TV.
Another is the "PICASO Universal Base Board" and "PICASO VGA/SVGA Graphics Controller" - this is not a direct shield but probably the best option I have seen.
Both the above items are available from Sparkfun and Little Bird Electronics among other places.
The OP asked how a VGA cable works, so I'll start with the wiring for a standard cable, which is a DE-15 15-pin connector (sort of like the DB-9 connector used for RS-232, but with an extra row):
H-SYNC and V-SYNC stand for horizontal and vertical sync. The rest are self-explanatory. H-SYNC and V-SYNC are digital (TTL) level signals, active low, and the color signals are analog, 0v (black) to 0.7v (full color).
As implied by the presence of the H-SYNC and V-SYNC, there is horizontal timing and vertical timing. This diagram shows the timing for 640x480 VGA, which was one of the original VGA formats.
The horizontal timing, shown at the top of the picture above, represents one line of the screen (e.g. 640 visible pixels of a 640x480 display). Between each line of pixel data, there is a horizontal blanking area where no video is shown (this originally was primarily used in TV's to allow the CRT trace to move back from the right side to the left side of the screen, ready for the next line).
The horizontal sync is used to start the timing of each line. It is not quite as wide as the blanking area. Just before the horizontal pulse, there is a delay called the front porch. And just following the horizontal pulse is another delay called the back porch.
Although 640 pixels are displayed, 800 pixels are actually needed per line: 96 for the horizontal sync, 48 for the back porch, 640 for the video, and 16 for the front porch.
As shown in the diagram, each line is 31.77 µs long. Diving this by 800 pixels results in 39.7 ns per pixel. This corresponds to a 25.1 MHz clock rate.
The lines are gathered into frames, shown at the bottom of the picture. Like the timing for each line, there is a vertical blanking interval at the beginning of each frame (this originally was primarily used in TV's to allow the CRT trace to move back from the bottom of the screen to the top, ready for the next frame). On some older CRT TV sets, it was possible to "roll" the picture down and actually see this interval as a black bar across the screen. Like the line timing, there is a front porch and back porch area in the timing.
Although 480 lines are displayed, 521 lines are actually needed per frame: 2 for the vertical sync, 29 for the back porch, 480 for the visible lines video, and 10 for the front porch.
As shown in the diagram, each frame is 16.784 ms long. This corresponds to a 59.5 Hz frame rate.
Best Answer
The question is not so much about what resolutions a monitor should support, the question should be about how to get a report of supported screen modes from the monitor to the PC. The monitor 'tells' the PC what modes are supported through I²C and the PC has to deal with that.
On Linux this looks like (notice I have 2 monitors attached):
Unfortunately for this question I have only HDMI attached monitors, but classic VGA monitors talk back to the PC too when attached through 15 pin sub-D. Check DDC (Display Data Channel) on Wikipedia
Actually with
--verbose
flag you get all sorts of cool details but that is way beyond the scope of this question.640×480 is a safe bet for all VGA monitors. So is 800×600 and most of the time 1024×768.