home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / GraKa / Picasso96Develop / Examples / OpenPIP.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  2.1 KB  |  90 lines

  1. /***********************************************************************
  2. * This is an example that shows how to open a p96 PIP Window 
  3. * to get input events and how to paint in that window.
  4. *
  5. ***********************************************************************/
  6.  
  7. #include    <proto/exec.h>
  8. #include    <proto/dos.h>
  9. #include <proto/picasso96.h>
  10.  
  11. #include    <intuition/intuition.h>
  12.  
  13. char    Template[] = "Width=W/N,Height=H/N,Pubscreen=PS/K";
  14. LONG    Array[] = { 0, 0, (LONG)"Workbench"};
  15.  
  16. struct Library    *P96Base;
  17.  
  18. void main(void)
  19. {
  20.     if(P96Base=OpenLibrary("Picasso96API.library",2)){
  21.         struct RDArgs    *rda;
  22.         struct Window    *wd;
  23.  
  24.         LONG    Width = 256, Height = 256;
  25.         char *PubScreenName = "Workbench";
  26.         
  27.         if(rda = ReadArgs(Template, Array, NULL)){
  28.             if(Array[0])    Width =*((LONG *)Array[0]);
  29.             if(Array[1])    Height=*((LONG *)Array[1]);
  30.             PubScreenName = (char *)Array[2];
  31.         }
  32.  
  33.         if(wd = p96PIP_OpenTags(
  34.                                         P96PIP_SourceFormat, RGBFB_R5G5B5, // RGBFB_Y4U2V2,
  35.                                         P96PIP_SourceWidth, 256,
  36.                                         P96PIP_SourceHeight, 256,
  37.                                         /* these tags are optional, but help */
  38.                                         WA_Title, "Picasso96 API PIP Test",
  39.                                         WA_Activate, TRUE,
  40.                                         WA_RMBTrap, TRUE,
  41.                                         WA_Width, Width,
  42.                                         WA_Height, Height,
  43.                                         WA_DragBar, TRUE,
  44.                                         WA_DepthGadget, TRUE,
  45.                                         WA_SimpleRefresh, TRUE,
  46.                                         WA_SizeGadget, TRUE,
  47.                                         WA_CloseGadget, TRUE,
  48.                                         WA_IDCMP, IDCMP_CLOSEWINDOW,
  49.                                         WA_PubScreenName, PubScreenName,
  50.                                         TAG_DONE)){
  51.  
  52.             struct IntuiMessage    *imsg;
  53.             BOOL    goahead = TRUE;
  54.  
  55.             struct RastPort *rp = NULL;
  56.             
  57.             p96PIP_GetTags(wd, P96PIP_SourceRPort, (ULONG)&rp, TAG_END);
  58.             
  59.             if(rp){
  60.                 UWORD    x, y;
  61.  
  62.                for(y=0; y<Height; y++){
  63.                   for(x=0; x<Width; x++){
  64.                     p96WritePixel(rp, x, y, (x*256+y)*256);
  65.                     }
  66.                 }
  67.             }
  68.  
  69.             do{
  70.                 WaitPort(wd->UserPort);
  71.                 while(imsg = (struct IntuiMessage *)GetMsg(wd->UserPort)){
  72.  
  73.                     switch(imsg->Class){
  74.                     case    IDCMP_CLOSEWINDOW:
  75.                         goahead = FALSE;
  76.                         break;
  77.                     }
  78.                     ReplyMsg((struct Message *)imsg);
  79.                 }
  80.             }while(goahead);
  81.  
  82.             p96PIP_Close(wd);
  83.         }
  84.  
  85.         if(rda)    FreeArgs(rda);
  86.  
  87.         CloseLibrary(P96Base);
  88.     }
  89. }
  90.