home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / graphics / primitives / AreaInfoExample.c next >
Encoding:
C/C++ Source or Header  |  1980-02-04  |  2.6 KB  |  75 lines

  1. /* AreaInfoExample
  2.    Insert this routine into the "wrapper" code at the end of the TEXT chapter.
  3.  
  4.    Copyright (c) 1990 Commodore-Amiga, Inc.
  5.   
  6.    This example is provided in electronic form by Commodore-Amiga, Inc. for
  7.    use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  8.    The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  9.    information on the correct usage of the techniques and operating system
  10.    functions presented in this example.  The source and executable code of
  11.    this example may only be distributed in free electronic form, via bulletin
  12.    board or as part of a fully non-commercial and freely redistributable
  13.    diskette.  Both the source and executable code (including comments) must
  14.    be included, without modification, in any copy.  This example may not be
  15.    published in printed form or distributed with any commercial product.
  16.    However, the programming techniques and support routines set forth in
  17.    this example may be used in the development of original executable
  18.    software products for Commodore Amiga computers.
  19.    All other rights reserved.
  20.    This example is provided "as-is" and is subject to change; no warranties
  21.    are made.  All use is at your own risk.  No liability or responsibility
  22.    is assumed.
  23. */
  24.  
  25. #define AREA_SIZE 200
  26.  
  27. BOOL example(struct Window *window)
  28. {
  29. register USHORT i;
  30. WORD areabuffer[AREA_SIZE];
  31. UWORD height, width;
  32. PLANEPTR planePtr = NULL;
  33. struct RastPort *rastPort = window->RPort;
  34. struct TmpRas tmpRas;
  35. struct AreaInfo areaInfo;
  36.  
  37. height = GfxBase->NormalDisplayRows;
  38. width  = GfxBase->NormalDisplayColumns;
  39.  
  40. planePtr = AllocRaster(width, height);
  41. if (planePtr)
  42.     {
  43.     for (i=0; i<AREA_SIZE; i++)
  44.         areabuffer[i] = 0;
  45.  
  46.     InitArea(&areaInfo, areabuffer, (AREA_SIZE*2)/5);
  47.     rastPort->AreaInfo = &areaInfo;
  48.  
  49.     InitTmpRas(&tmpRas, planePtr, RASSIZE(width, height));
  50.     rastPort->TmpRas = &tmpRas;
  51.  
  52.     /* Area routines need a temporary raster buffer at least as large as the
  53.      * largest object to be drawn.  If a single task uses multiple RastPorts,
  54.      * it is sometimes possible to share the same TmpRas structure among
  55.      * multiple RastPorts.  Multiple tasks, however, cannot share a TmpRas,
  56.      * as each task won't know when another task has a drawing partially
  57.      * completed.
  58.     */
  59.  
  60.     AreaMove(rastPort, 0, 0); 
  61.     AreaDraw(rastPort, 0, 100); 
  62.     AreaDraw(rastPort, 100, 100);
  63.  
  64.     AreaMove(rastPort, 50, 10);
  65.     AreaDraw(rastPort, 50, 50);
  66.     AreaDraw(rastPort, 100, 50);
  67.  
  68.     AreaEnd (rastPort);
  69.  
  70.     FreeRaster(planePtr, width, height);
  71.     }
  72.     return(WAIT_FOR_CLOSE);
  73. }
  74.  
  75.