[comp.sys.amiga.programmer] Intuition Double Buffering

drpwilliams@tiger.uwaterloo.ca (Don Williams) (03/25/91)

I am trying to double buffer LEGALLY under Intuition.  The code I
have come up with works, however, alternate gadget images only show
up in the original bitmap, and screen grab programs can only get the
original bitmap regardless of whether the alternate bitmap is being
displayed.  The code I am using follows.  Can anyone suggest a fix
or a better way??? (The method must be Intuition compatible)


/******************************************************************
 * Name: switch_bitmaps
 *
 * Purpose: This routine will switch bitmaps for the main screen to
 *          allow double buffering of the display under intuition.
 ******************************************************************/
void switch_bitmaps()
{
   /*
    * If bitmap being shown is main_bm, then switch it to alternate_bm.
    * Otherwise, link back in the main_bm.
    */
   if (((main_screen_ptr->ViewPort).RasInfo)->BitMap == main_bm)
   {
      ((main_screen_ptr->ViewPort).RasInfo)->BitMap = alternate_bm;
      /* Record which bitmap can be used to draw into. */
      current_bm_ptr = main_bm;
   } /* end if */
   else
   {
      ((main_screen_ptr->ViewPort).RasInfo)->BitMap = main_bm;
      /* Record which bitmap can be used to draw into. */
      current_bm_ptr = alternate_bm;
   } /* end else */
   refresh_screen();
} /* end switch_bitmaps */


/**********************************************************************
 * Name: refresh_screen
 *
 * Purpose: This routine is used to double buffer the intuition display
 *          screen.
 **********************************************************************/
void refresh_screen()
{
   /* Create new copper instructions for this screen. */
   MakeScreen(main_screen_ptr);

   /* Merge all copper lists. */
   MrgCop(intuition_view);

   /* Use new copper lists to show the new screen. */
   LoadView(intuition_view);

   /* Wait for top of video frame. */
   WaitTOF();
} /* end refresh_screen */

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (04/03/91)

In article <1991Mar24.170937.24081@watdragon.waterloo.edu> drpwilliams@tiger.uwaterloo.ca (Don Williams) writes:
>I am trying to double buffer LEGALLY under Intuition.  The code I
>have come up with works, however, alternate gadget images only show
>up in the original bitmap, and screen grab programs can only get the
>original bitmap regardless of whether the alternate bitmap is being
>displayed.  The code I am using follows.  Can anyone suggest a fix
>or a better way??? (The method must be Intuition compatible)

Intuition does not really support double-buffering.  If you want something
to appear in both buffers, then you have to copy the data to the second.
For instance, if you open a window and it is displayed into one of the buffers,
you must then copy the window into the second buffer for it to appear there.
If you do not copy the data, then the object will appear to flicker.

>void switch_bitmaps()
>void refresh_screen()

Look in the ROM Kernel Manual: Libraries and Devices for an example of a
double-buffered screen.  There is one in the Graphics: Sprites, Bobs and
Animation chapter, specifically look at the DrawGels() routine that begins
on page 501.
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky