home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / opengl / glutdemo / test7.c < prev    next >
C/C++ Source or Header  |  1999-05-11  |  3KB  |  126 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  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. #ifdef __sgi
  9. #include <malloc.h>
  10. #endif
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <glut.h>
  14.  
  15. int w1, w2;
  16.  
  17. void
  18. display(void)
  19. {
  20.   glClear(GL_COLOR_BUFFER_BIT);
  21. }
  22.  
  23. void
  24. time6(int value)
  25. {
  26.   if (value != 6)
  27.     __glutFatalError("FAIL: time6 expected 6");
  28.   printf("change icon tile for both windows\n");
  29.   glutSetWindow(w1);
  30.   glutSetIconTitle("icon1");
  31.   glutSetWindow(w2);
  32.   glutSetIconTitle("icon2");
  33.   printf("PASS: test7\n");
  34.   exit(0);
  35. }
  36.  
  37. void
  38. time5(int value)
  39. {
  40.   if (value != 5)
  41.     __glutFatalError("FAIL: time5 expected 5");
  42.   printf("iconify both windows\n");
  43.   glutSetWindow(w1);
  44.   glutIconifyWindow();
  45.   glutSetWindow(w2);
  46.   glutIconifyWindow();
  47.   glutTimerFunc(1000, time6, 6);
  48. }
  49.  
  50. void
  51. time4(int value)
  52. {
  53.   if (value != 4)
  54.     __glutFatalError("FAIL: time4 expected 4");
  55.   printf("reshape and reposition window\n");
  56.   glutSetWindow(w1);
  57.   glutReshapeWindow(250, 250);
  58.   glutPositionWindow(20, 20);
  59.   glutSetWindow(w2);
  60.   glutReshapeWindow(150, 150);
  61.   glutPositionWindow(250, 250);
  62.   glutTimerFunc(1000, time5, 5);
  63. }
  64.  
  65. void
  66. time3(int value)
  67. {
  68.   if (value != 3)
  69.     __glutFatalError("FAIL: time3 expected 3");
  70.   printf("show both windows again\n");
  71.   glutSetWindow(w1);
  72.   glutShowWindow();
  73.   glutSetWindow(w2);
  74.   glutShowWindow();
  75.   glutTimerFunc(1000, time4, 4);
  76. }
  77.  
  78. void
  79. time2(int value)
  80. {
  81.   if (value != 2)
  82.     __glutFatalError("FAIL: time2 expected 2");
  83.   printf("hiding w1; iconify w2\n");
  84.   glutSetWindow(w1);
  85.   glutHideWindow();
  86.   glutSetWindow(w2);
  87.   glutIconifyWindow();
  88.   glutTimerFunc(1000, time3, 3);
  89. }
  90.  
  91. void
  92. time1(int value)
  93. {
  94.   if (value != 1)
  95.     __glutFatalError("FAIL: time1 expected 1");
  96.   printf("changing window titles\n");
  97.   glutSetWindow(w1);
  98.   glutSetWindowTitle("changed title");
  99.   glutSetWindow(w2);
  100.   glutSetWindowTitle("changed other title");
  101.   glutTimerFunc(2000, time2, 2);
  102. }
  103.  
  104. void
  105. main(int argc, char **argv)
  106. {
  107. #ifdef __sgi
  108.   mallopt(M_DEBUG, 1);
  109. #endif
  110.   glutInit(&argc, argv);
  111.   w1 = glutCreateWindow("test 1");
  112.   glutDisplayFunc(display);
  113.   w2 = glutCreateWindow("test 2");
  114.   glutDisplayFunc(display);
  115.   glutTimerFunc(1000, time1, 1);
  116.   glutMainLoop();
  117. }
  118.  
  119.  
  120. __glutFatalError(char *msg) {
  121.  
  122.   puts(msg);
  123.   exit(1);
  124.  
  125. }
  126.