Graphics Reference
In-Depth Information
Before each bit is copied, one checks the appropriate bit in the texture array. A “1”
means that the bit is to be copied, a “0,” that it is not. If a source bit sB is to be copied,
then the target bit tB is replaced by sB op tB using the current copying mode op .
Although the abstract code for a bitBlt operation is straightforward, the tricky
part is to implement it as efficiently as possible. For that reason, such operations are
usually implemented in assembly language. A complicating factor is when addresses
do not fall on word boundaries. Efficient coding is absolutely essential here and can
speed up the speed of the procedure by orders of magnitude!
An important application of BitBlt procedures is managing a cursor on the screen.
What this involves is mapping predefined bit maps to specified locations on the screen.
A cursor corresponds to a small rectangle of bits. In Section 1.3 we already described
a simple way to move a cursor is using xor mode along with the advantages and dis-
advantages of this method.
2.11
2D Animation
The object of this section is to describe a few simple aspects of two-dimensional ani-
mation. The general topic is much too large to do more than that here, especially since
much of it is not really a topic in geometric modeling per se. On the other hand, many
of the techniques used in two-dimensional computer animation belong in a discus-
sion of raster graphics. This is certainly true of that part of animation which deals
with showing moving objects and which lends itself to a lot of fun programming exer-
cises. Keep in mind though that animation techniques have changed along with hard-
ware. All we shall basically do here is describe a few interesting tricks that deal with
Boolean operations on bits. These tricks were especially important in the early days
of graphics where one had only a single frame buffer and not the multiple buffers that
one finds in graphics systems today. We shall have a little to say about animation of
three-dimensional objects in Sections 4.13 and 4.14.
Showing moving objects is accomplished by showing a sequence of still objects,
where each individual picture shows the objects moved slightly from their previous
position. Here are some simple methods by which one can perform such animation,
starting with the most basic:
(1) Redraw the whole screen for each new image.
(2) If the objects consist of lines, then simply erase the current lines and redraw
them at the new location.
(3) Erase/draw objects using block write commands.
(4) Use an approach similar to (3), except let each block have “trailing” blanks,
so that each new block write erases and draws simultaneously. This reduces the
number of block writes. An example of this is shown in Figure 2.21. If we wanted to
show a ball moving from left to right, we could show the ball at the sequence of loca-
tions shown in (a). Rather than writing blocks of pixels the size of the ball, we could
write a block shown in (b) which simultaneously erases the previous ball as it writes
the new one.
(5) Use bit operations such as xor , and , or more general BitBlt procedures. We
have already discussed in Section 1.3 how xor mode is useful in moving a cursor
Search WWH ::




Custom Search