Game Development Reference
In-Depth Information
Color Buffers and Vertical Sync
Newer hardware featured more than enough memory to have a color buffer that
could store the pixel data for the entire screen at once. But this did not mean that
the game loop could ignore the CRT gun entirely. Suppose the electron gun is half
way through drawing the screen. At this exact time, it just so happens that the
game loop hits the “generate outputs” phase. So it starts writing the pixel informa-
tion into the color buffer for the next frame, while the CRT is still drawing the last
frame. The result of this is screen tearing , which is when the screen shows part of
two different frames at once. An example of this is shown in Figure 2.2 .
Figure 2.2 Screen tearing caused by updating video data while the CRT is draw-
ing.
What's worse is that the game loop might not actually finish writing all its image
information for the next frame before it gets drawn on the screen. So not only will
the second half of the screen be the wrong frame, it may even be missing graphical
elements!
One solution to this problem is to synchronize it so the game loop renders only
during the vertical blank interval. This will fix the split-image problem, but it lim-
Search WWH ::




Custom Search