Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!watserv1!watdragon!tiger!drpwilliams
From: drpwilliams@tiger.uwaterloo.ca (Don Williams)
Subject: Intuition Double Buffering
Message-ID: <1991Mar24.170937.24081@watdragon.waterloo.edu>
Sender: daemon@watdragon.waterloo.edu (Owner of Many System Processes)
Organization: University of Waterloo
Distribution: na
Date: Sun, 24 Mar 1991 17:09:37 GMT
Lines: 56

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 */
