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

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1996. */
  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 GLUT's glutWindowStatusFunc rotuine. */
  9.  
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <GL/glut.h>
  14.  
  15. int win, subwin, cover;
  16.  
  17. void
  18. display(void)
  19. {
  20.   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  21.   glutSwapBuffers();
  22. }
  23.  
  24. /* ARGSUSED */
  25. void
  26. time_end(int value)
  27. {
  28.   printf("PASS: test22\n");
  29.   exit(0);
  30. }
  31.  
  32. /* ARGSUSED */
  33. void
  34. time5(int value)
  35. {
  36.   glutSetWindow(subwin);
  37.   glutPositionWindow(40, 40);
  38. }
  39.  
  40. /* ARGSUSED */
  41. void
  42. time4(int value)
  43. {
  44.   glutSetWindow(subwin);
  45.   glutShowWindow();
  46. }
  47.  
  48. /* ARGSUSED */
  49. void
  50. time3(int value)
  51. {
  52.   glutSetWindow(subwin);
  53.   glutHideWindow();
  54. }
  55.  
  56. int sub_state = 0;
  57. int cover_state = 0;
  58. int state = 0;
  59.  
  60. void
  61. coverstat(int status)
  62. {
  63.   if (cover != glutGetWindow()) {
  64.     printf("ERROR: test22\n");
  65.     exit(1);
  66.   }
  67.   printf("%d: cover = %d\n", cover_state, status);
  68.   switch(cover_state) {
  69.   case 0:
  70.     if (status != GLUT_FULLY_RETAINED) {
  71.       printf("ERROR: test22\n");
  72.       exit(1);
  73.     }
  74.     glutTimerFunc(1000, time3, 0);
  75.     break;
  76.   default:
  77.     printf("ERROR: test22\n");
  78.     exit(1);
  79.     break;
  80.   }
  81.   cover_state++;
  82. }
  83.  
  84. /* ARGSUSED */
  85. void
  86. time2(int value)
  87. {
  88.   cover = glutCreateSubWindow(win, 5, 5, 105, 105);
  89.   glClearColor(0.0, 1.0, 0.0, 0.0);
  90.   glutDisplayFunc(display);
  91.   glutWindowStatusFunc(coverstat);
  92. }
  93.  
  94. void
  95. substat(int status)
  96. {
  97.   if (subwin != glutGetWindow()) {
  98.     printf("ERROR: test22\n");
  99.     exit(1);
  100.   }
  101.   printf("%d: substat = %d\n", sub_state, status);
  102.   switch(sub_state) {
  103.   case 0:
  104.     if (status != GLUT_FULLY_RETAINED) {
  105.       printf("ERROR: test22\n");
  106.       exit(1);
  107.     }
  108.     glutTimerFunc(1000, time2, 0);
  109.     break;
  110.   case 1:
  111.     if (status != GLUT_FULLY_COVERED) {
  112.       printf("ERROR: test22\n");
  113.       exit(1);
  114.     }
  115.     break;
  116.   case 2:
  117.     if (status != GLUT_HIDDEN) {
  118.       printf("ERROR: test22\n");
  119.       exit(1);
  120.     }
  121.     glutTimerFunc(1000, time4, 0);
  122.     break;
  123.   case 3:
  124.     if (status != GLUT_FULLY_COVERED) {
  125.       printf("ERROR: test22\n");
  126.       exit(1);
  127.     }
  128.     glutTimerFunc(1000, time5, 0);
  129.     break;
  130.   case 4:
  131.     if (status != GLUT_PARTIALLY_RETAINED) {
  132.       printf("ERROR: test22\n");
  133.       exit(1);
  134.     }
  135.     glutTimerFunc(1000, time_end, 0);
  136.     break;
  137.   default:
  138.     printf("ERROR: test22\n");
  139.     exit(1);
  140.     break;
  141.   }
  142.   sub_state++;
  143. }
  144.  
  145. /* ARGSUSED */
  146. void
  147. time1(int value)
  148. {
  149.   subwin = glutCreateSubWindow(win, 10, 10, 100, 100);
  150.   glClearColor(0.0, 1.0, 1.0, 0.0);
  151.   glutDisplayFunc(display);
  152.   glutWindowStatusFunc(substat);
  153. }
  154.  
  155. void
  156. winstat(int status)
  157. {
  158.   if (win != glutGetWindow()) {
  159.     printf("ERROR: test22\n");
  160.     exit(1);
  161.   }
  162.   printf("%d: win = %d\n", state, status);
  163.   switch(state) {
  164.   case 0:
  165.     if (status != GLUT_FULLY_RETAINED) {
  166.       printf("ERROR: test22\n");
  167.       exit(1);
  168.     }
  169.     glutTimerFunc(1000, time1, 0);
  170.     break;
  171.   case 1:
  172.     if (status != GLUT_PARTIALLY_RETAINED) {
  173.       printf("ERROR: test22\n");
  174.       exit(1);
  175.     }
  176.     break;
  177.   default:
  178.     printf("ERROR: test22\n");
  179.     exit(1);
  180.     break;
  181.   }
  182.   state++;
  183. }
  184.  
  185. /* ARGSUSED */
  186. void
  187. visbad(int state)
  188. {
  189.   printf("ERROR: test22\n");
  190.   exit(1);
  191. }
  192.  
  193. int
  194. main(int argc, char **argv)
  195. {
  196.   glutInit(&argc, argv);
  197.  
  198.   glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
  199.   win = glutCreateWindow("test22");
  200.   glClearColor(1.0, 0.0, 1.0, 0.0);
  201.   glutDisplayFunc(display);
  202.   glutVisibilityFunc(visbad);
  203.   glutVisibilityFunc(NULL);
  204.   glutWindowStatusFunc(NULL);
  205.   glutVisibilityFunc(NULL);
  206.   glutWindowStatusFunc(winstat);
  207.   glutMainLoop();
  208.   return 0;             /* ANSI C requires main to return int. */
  209. }
  210.