[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

To produce smooth animation or similar effects, it is occasionally
necessary to double-buffer your display.  To prevent the user from seeing
your graphics rendering while it is in progress, you will want to draw
into one memory area while actually displaying a different area.

There are two methods of creating and displaying a double-buffered
display.  The simplest method is to create two complete Views and switch
back and forth between them with loadview() and waittof().

The second method consists of creating two separate display areas and two
sets of pointers to those areas for a single view.  this is more
complicated but takes less memory.

  * Allocate one viewport structure and one view structure.

  * Allocate two bitmap structures and one rasinfo structure. initialize
    each BitMap structure to describe one drawing area and allocate
    memory for the bitplanes themselves. Initialize the RasInfo
    structure, setting the rasinfo.bitmap field to the address of one of
    the two BitMaps you created.

  * Call makevport(), mrgcop() and loadview(). when you call mrgcop(),
    the system uses the information you have provided to create a Copper
    instruction list for the Copper to execute.  The system allocates
    memory for a long-frame (LOF) Copper list and, if this is an
    interlaced display, a short-frame (SHF) Copper list as well.  The
    system places a pointer to the long-frame Copper list in
    view.lofcprlist and a pointer to a short-frame copper list (if this
    is an interlaced display) in view.shfcprlist.  the copper instruction
    stream referenced by these pointers applies to the first bitmap.

  * Save the values in view.lofcprlist and view.shfcprlist and reset
    these fields to zero.  Place a pointer to the second bitmap structure
    in the rasinfo.bitmap field.  next call makevport() and mrgcop().

  * When you perform mrgcop() with the copper instruction list fields of
    the view set to zero, the system automatically allocates and fills in
    a new list of instructions for the Copper.  Now you have created two
    sets of instruction streams for the Copper, one that works with data
    in the first bitmap and the other that works with data in the second
    BitMap.

  * You can save pointers to the second list of Copper instructions as
    well.  Then, to perform the double-buffering, alternate between the
    two Copper lists.  The code for the double-buffering loop would be as
    follows: call waittof(), change the copper instruction list pointers
    in the view, call loadview() to show one of the bitmaps while drawing
    into the other BitMap, and repeat.

Remember that you will have to call freecprlist() on both sets of copper
lists when you have finished.