home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / graphics / gl.pak / DEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  5.0 KB  |  156 lines

  1. #ifndef lint
  2. static char sccsid[] = "@(#) demo.c 5.1 89/02/20";
  3. #endif
  4. /*
  5.  *    Copyright (c) David T. Lewis 1987, 1988
  6.  *    All rights reserved.
  7.  *
  8.  *    Permission is granted to use this for any personal noncommercial use.
  9.  *    You may not distribute source or executable code for profit, nor
  10.  *    may you distribute it with a commercial product without the written
  11.  *    consent of the author.  Please send modifications to the author for
  12.  *    inclusion in updates to the program.  Thanks.
  13.  */
  14. #include "config.h"
  15. #include "gl.h"
  16. #include <stdio.h>
  17. #if MIX_C
  18. #else
  19. #include <time.h>
  20. #endif /* MIX_C */
  21. extern int lines(), strings(), chars(), strokeset(), fillscreen();
  22. extern int charset(), ellipses(), arcs(), testplot(), showcursor();
  23. extern int linestyles(), curvestyles();
  24. static int mode;
  25. void usage(progname)  
  26. char *progname;
  27. {
  28.     fprintf (stderr,"Usage:  %s <mode>\n\n",progname);
  29.     fprintf (stderr,"Where <mode> is:\n",0);
  30.     fprintf (stderr,"\t4 (CGA 4 color 320 x 200)\n",0);
  31.     fprintf (stderr,"\t6 (CGA 2 color 640 x 200)\n",0);
  32.     fprintf (stderr,"\t8 (Hercules page 0, 720 x 348)\n",0);
  33.     fprintf (stderr,"\t9 (Hercules page 1, 720 x 348)\n",0);
  34.     fprintf (stderr,"\t16 (EGA color 640 x 350)\n",0);
  35.     fprintf (stderr,"\t256 (IBM / Epson compatible printer)\n",0);
  36.     fprintf (stderr,"\t257 (Laserjet+ printer)\n\n",0);
  37. }
  38. main(argc,argv)
  39. int argc;
  40. char *argv[];
  41. {
  42.     char str[80];
  43.     long time();
  44.     struct tm *gmtime();
  45.     void srand();
  46.     printf("\nThis demonstration will show the operation of the gl ",0);
  47.     printf("graphics functions.\n",0);
  48.     printf("The <delete> key stops the demo.  Press <return> ",0);
  49.     printf("to view each\n",0);
  50.     printf("successive screen.\n\n",0);
  51.     printf("Note: The GLMODE shell variable may be used to specify ",0);
  52.     printf("the graphics\n",0);
  53.     printf("mode to use.\n\n",0);
  54.     printf("Press <return> to continue...",0);
  55.     gets(str);
  56.     /* Get the mode to use. */
  57.     if (argc < 2) mode = ENV_MODE;
  58.     else if (argc == 2)  {
  59.         if (sscanf(argv[1],"%d",&(mode)) != 1)  {
  60.             usage(argv[0]);
  61.             exit (1);
  62.         }
  63.     }
  64.     else  {
  65.         usage(argv[0]);
  66.         exit (1);
  67.     }
  68.     /* Set video mode.    */
  69.     if (g_init(mode))  {
  70.         usage(argv[0]);
  71.         fprintf(stderr,"WARNING:  Possible invalid shared memory ",0);
  72.         fprintf(stderr,"key for requested video mode.\n",0);
  73.         exit (1);
  74.     }
  75.     /* Draw patterns.    */
  76.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  77.     if (lines()) fprintf(stderr,"Failed call to lines().\n");
  78.     if (mode > MAXVIDEO)
  79.         printf("\nPress <Return> to send to printer...",0);
  80.     gets(str);
  81.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  82.     g_clear();
  83.     if (linestyles()) fprintf(stderr,"Failed call to linestyles().\n");
  84.     if (mode > MAXVIDEO)
  85.         printf("\nPress <Return> to send to printer...",0);
  86.     gets(str);
  87.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  88.     g_clear();
  89.     if (strings()) fprintf(stderr,"Failed call to strings().\n");
  90.     if (mode > MAXVIDEO)
  91.         printf("\nPress <Return> to send to printer...",0);
  92.     gets(str);
  93.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  94.     g_clear();
  95.     slanttext();
  96.     if (mode > MAXVIDEO)
  97.         printf("\nPress <Return> to send to printer...",0);
  98.     gets(str);
  99.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  100.     g_clear();
  101.     strokeset();
  102.     if (mode > MAXVIDEO)
  103.         printf("\nPress <Return> to send to printer...",0);
  104.     gets(str);
  105.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  106.     g_clear();
  107.     if (chars()) fprintf(stderr,"Failed call to chars().\n");
  108.     if (mode > MAXVIDEO)
  109.         printf("\nPress <Return> to send to printer...",0);
  110.     gets(str);
  111.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  112.     g_clear();
  113.     fillscreen();
  114.     if (mode > MAXVIDEO)
  115.         printf("\nPress <Return> to send to printer...",0);
  116.     gets(str);
  117.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  118.     g_clear();
  119.     charset();
  120.     if (mode > MAXVIDEO)
  121.         printf("\nPress <Return> to send to printer...",0);
  122.     gets(str);
  123.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  124.     g_clear();
  125.     ellipses();
  126.     if (mode > MAXVIDEO)
  127.         printf("\nPress <Return> to send to printer...",0);
  128.     gets(str);
  129.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  130.     g_clear();
  131.     curvestyles();
  132.     if (mode > MAXVIDEO)
  133.         printf("\nPress <Return> to send to printer...",0);
  134.     gets(str);
  135.     if (mode > MAXVIDEO) printf("\nRasterizing output...",0);
  136.     g_clear();
  137.     arcs();
  138.     showcursor();
  139.     g_finish();
  140.     printf("\n\n\n\nThe next demonstration screen will use the ",0);
  141.     printf("plot(3) interface, rather than\n",0);
  142.     printf("direct calls to the gl library.  The plot(3) interface ",0);
  143.     printf("determines graphic \n",0);
  144.     printf("mode from the GLMODE shell variable, or if GLMODE is not ",0);
  145.     printf("defined, uses a \n",0);
  146.     printf("default mode value (defined in config.h). \n\n",0);
  147.     printf("If you called this program with an argument on the ",0);
  148.     printf("command line, the \n",0);
  149.     printf("next screen may use a different graphics mode ",0);
  150.     printf("than you specified. \n\n",0);
  151.     printf("Press <return> to continue or <delete> to stop...",0);
  152.     gets(str);
  153.     testplot();
  154.     gets(str);
  155. }
  156.