home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / sviluppo / mesa-glut / test / glut / test23.c < prev    next >
C/C++ Source or Header  |  1998-10-23  |  4KB  |  139 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1997. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. /* This tests unexpected interactions between
  9.    glutInitDisplayMode and glutInitDisplayString. */
  10.  
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <GL/glut.h>
  15.  
  16. int modes[] =
  17. {
  18.   GLUT_RGB | GLUT_SINGLE,
  19.   GLUT_RGB | GLUT_DOUBLE,
  20.   GLUT_INDEX | GLUT_SINGLE,
  21.   GLUT_INDEX | GLUT_DOUBLE
  22. };
  23. #define NUM_MODES (sizeof(modes)/sizeof(modes[0]))
  24.  
  25. char *strings[] =
  26. {
  27.   "rgb double",
  28.   "rgba double",
  29.   "rgba single",
  30.   "index",
  31.   "index double",
  32.   "rgb samples=4",
  33.   "stencil depth red green blue alpha conformant auxbufs buffer acc acca double rgb rgba",
  34.   "stereo index samples slow",
  35.   NULL
  36. };
  37.  
  38. char *ostrings[] =
  39. {
  40.   "index double",
  41.   "index single",
  42.   "index buffer=4",
  43.   "index buffer=8",
  44.   "index buffer~4",
  45.   "index buffer=4 depth",
  46.   NULL
  47. };
  48.  
  49. int verbose;
  50.  
  51. int
  52. main(int argc, char **argv)
  53. {
  54.   int k, i, j, win;
  55.   int num, exists;
  56.   char mode[200];
  57.  
  58.   glutInit(&argc, argv);
  59.   if (argc > 1) {
  60.     if (!strcmp(argv[1], "-v")) {
  61.       verbose = 1;
  62.     }
  63.   }
  64.   glutInitWindowPosition(10, 10);
  65.   glutInitWindowSize(200, 200);
  66.   for (k = 0; k < NUM_MODES; k++) {
  67.     glutInitDisplayMode(modes[k]);
  68.     printf("Display Mode = %d (%s,%s)\n", modes[k],
  69.       modes[k] & GLUT_INDEX ? "index" : "rgba",
  70.       modes[k] & GLUT_DOUBLE ? "double" : "single");
  71.     for (i = 0; strings[i]; i++) {
  72.       glutInitDisplayString(strings[i]);
  73.       if (glutGet(GLUT_DISPLAY_MODE_POSSIBLE)) {
  74.         if (verbose)
  75.           printf("  Possible: %s\n", strings[i]);
  76.         win = glutCreateWindow("test23");
  77.         if (verbose)
  78.           printf("    Created: %s\n", strings[i]);
  79.         for (j = 0; ostrings[j]; j++) {
  80.           glutInitDisplayString(ostrings[j]);
  81.           if (glutLayerGet(GLUT_OVERLAY_POSSIBLE)) {
  82.             if (verbose)
  83.               printf("    Overlay possible: %s\n", ostrings[j]);
  84.             glutEstablishOverlay();
  85.             if (verbose)
  86.               printf("      Overlay establish: %s\n", ostrings[j]);
  87.             glutRemoveOverlay();
  88.             if (verbose)
  89.               printf("        Overlay remove: %s\n", ostrings[j]);
  90.           }
  91.         }
  92.         glutDestroyWindow(win);
  93.         if (verbose)
  94.           printf("      Destroyed: %s\n", strings[i]);
  95.       } else {
  96.         if (verbose)
  97.           printf("Not possible: %s\n", strings[i]);
  98.       }
  99.     }
  100.   }
  101.  
  102.   glutInitDisplayString(NULL);
  103.  
  104.   num = 1;
  105.   do {
  106.     sprintf(mode, "rgb num=%d", num);
  107.     glutInitDisplayString(mode);
  108.     exists = glutGet(GLUT_DISPLAY_MODE_POSSIBLE);
  109.     if (exists) {
  110.       if (verbose)
  111.         printf("  Possible: %s\n", mode);
  112.       win = glutCreateWindow("test23");
  113.       if (verbose)
  114.         printf("    Created: %s\n", mode);
  115.       glutDestroyWindow(win);
  116.       if (verbose)
  117.         printf("      Destroyed: %s\n", mode);
  118.       sprintf(mode, "rgb num=0x%x", num);
  119.       glutInitDisplayString(mode);
  120.       exists = glutGet(GLUT_DISPLAY_MODE_POSSIBLE);
  121.       if (!exists) {
  122.         printf("FAIL: test23 (hex num= don't work)\n");
  123.         exit(1);
  124.       }
  125.       win = glutCreateWindow("test23");
  126.       glutDestroyWindow(win);
  127.       num++;
  128.     } else {
  129.       if (verbose)
  130.         printf("Not possible: %s\n", mode);
  131.     }
  132.   } while (exists);
  133.  
  134.   glutInitDisplayString(NULL);
  135.  
  136.   printf("PASS: test23\n");
  137.   return 0;             /* ANSI C requires main to return int. */
  138. }
  139.