home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / C / DoubleBuffer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-16  |  1.7 KB  |  67 lines

  1. /*
  2. ** Double Buffer Demo
  3. ** ------------------
  4. ** This just shows how to double buffer the screen.
  5. **
  6. */
  7.  
  8. #include <proto/games.h>
  9. #include <proto/exec.h>
  10.  
  11. #define AMT_PLANES 5
  12.  
  13. struct GMSBase *GMSBase;
  14. extern struct ExecBase *SysBase;
  15.  
  16. struct Picture pic = {
  17.        PCV1,              /* Version header */
  18.        0,                 /* Destination */
  19.        320,0,256,         /* Width, Height */
  20.        AMT_PLANES,        /* Amount of Planes */
  21.        32,                /* Amount of colours */
  22.        0,                 /* Palette */
  23.        LORES|COL12BIT,    /* Screen mode */
  24.        INTERLEAVED,       /* Destination */
  25.        GETPALETTE,        /* Parameters */
  26.        "GAMESLIB:data/IFF.Pic320"
  27.        };
  28.  
  29. struct Picture *picture = &pic;
  30. struct GameScreen *GameScreen;
  31.  
  32. /*=========================================================================*/
  33.  
  34. void main(void)
  35. {
  36.    if (GMSBase = (struct GMSBase *) OpenLibrary("games.library", 0)) {
  37.       SetUserPrefs(0);
  38.  
  39.       if (GameScreen = AddScreenTags(TAGS,NULL,
  40.            GSA_Planes,AMT_PLANES,
  41.            GSA_ScrMode,LORES|COL12BIT,
  42.            GSA_ScrType,INTERLEAVED,
  43.            GSA_ScrWidth,320,
  44.            GSA_ScrHeight,256,
  45.            GSA_Attrib,DBLBUFFER,
  46.            TAGEND)) {
  47.  
  48.          picture->Data = GameScreen->MemPtr1;
  49.          if (LoadPic(picture) == ERR_OK) {
  50.            GameScreen->Palette = picture->Palette;
  51.            UpdatePalette(GameScreen);
  52.            ShowScreen(GameScreen);
  53.            while (!(ReadMouse(JPORT1)&MB_LMB)) {
  54.              WaitSVBL();
  55.              SwapBuffers(GameScreen);
  56.            }
  57.          FreePic(picture);
  58.          }
  59.       DeleteScreen(GameScreen);
  60.       }
  61.    CloseLibrary((struct Library *)GMSBase);
  62.    }
  63. }
  64.  
  65. /*=========================================================================*/
  66.  
  67.