home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / CBMDevKit3.dms / CBMDevKit3.adf / compatibility / depthawarevisitor.c next >
Encoding:
C/C++ Source or Header  |  1993-11-17  |  2.9 KB  |  100 lines

  1. /* depthawarevisitor.c
  2.  *
  3.  * (c) Copyright 1992 Commodore-Amiga, Inc.  All rights reserved.
  4.  *
  5.  * This software is provided as-is and is subject to change; no warranties
  6.  * are made.  All use is at your own risk.  No liability or responsibility
  7.  * is assumed.
  8.  *
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <intuition/intuition.h>
  13. #include <graphics/displayinfo.h>
  14. #include <dos/dos.h>
  15.  
  16. #include <clib/exec_protos.h>
  17. #include <clib/intuition_protos.h>
  18. #include <clib/graphics_protos.h>
  19. #include <clib/dos_protos.h>
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23.  
  24.  
  25. struct Library *IntuitionBase;
  26. struct Library *GfxBase;
  27. struct Screen  *screen = NULL;
  28.  
  29.  
  30. void Quit(char *whytext, LONG failcode)
  31. {
  32.     if(*whytext) printf("%s\n",whytext);
  33.  
  34.     if (screen)        UnlockPubScreen(NULL, screen);
  35.     if (IntuitionBase)    CloseLibrary(IntuitionBase);
  36.     if (GfxBase)    CloseLibrary(GfxBase);
  37.  
  38.     exit(failcode);
  39. }
  40.  
  41.  
  42. void main(void)
  43. {
  44.     struct Screen *screen;
  45.     struct DrawInfo *drawinfo;
  46.     struct Window *window;
  47.     UWORD depth;
  48.  
  49.     if ((GfxBase = OpenLibrary("graphics.library",36))==NULL)
  50.         Quit("graphics.library is too old <V36",RETURN_FAIL);
  51.  
  52.     if ((IntuitionBase = OpenLibrary("intuition.library",36))==NULL)
  53.         Quit("intuition.library is too old <V36",RETURN_FAIL);
  54.  
  55.     if (!(screen = LockPubScreen(NULL)))
  56.         Quit("Can't lock default public screen",RETURN_FAIL);
  57.  
  58.     /* Here's where we'll ask Intuition about the screen. */
  59.     if((drawinfo=GetScreenDrawInfo(screen)) == NULL)
  60.     Quit("Can't get DrawInfo",RETURN_FAIL);
  61.  
  62.     depth=drawinfo->dri_Depth;
  63.  
  64.     /* Because Intuition allocates the DrawInfo structure,
  65.      * we have to tell it when we're done, to get the memory back.
  66.      */
  67.     FreeScreenDrawInfo(screen, drawinfo);
  68.  
  69.     /* This next line takes advantage of the stack-based amiga.lib
  70.      * version of OpenWindowTags.
  71.      */
  72.     if (window = OpenWindowTags(NULL, WA_PubScreen ,screen,
  73.                                       WA_Left      ,0,
  74.                                       WA_Width     ,screen->Width,
  75.                                       WA_Top       ,screen->BarHeight,
  76.                                       WA_Height    ,screen->Height - screen->BarHeight,
  77.                                       WA_Flags     ,WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|
  78.                                                     ACTIVATE|SIMPLE_REFRESH|NOCAREREFRESH,
  79.                                       WA_Title     ,"Big Visitor",
  80.                                       TAG_END))
  81.     {
  82.  
  83.         printf("depth=%d\n",depth);
  84.         
  85.         /* All our window event handling might go here */
  86.  
  87.         Delay(TICKS_PER_SECOND * 10);
  88.  
  89.         /* Of course, some other program might come along
  90.          * and change the attributes of the screen that we read from
  91.          * DrawInfo, but that's a mean thing to do to a public screen,
  92.          * so let's hope it doesn't happen.
  93.          */
  94.  
  95.         CloseWindow(window);
  96.     }
  97.  
  98. Quit("",RETURN_OK);    /* clean up (close/unlock) and exit */
  99. }
  100.