Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software and
  5. * its documentation for any purpose is hereby granted without fee, provided
  6. * that (i) the above copyright notices and this permission notice appear in
  7. * all copies of the software and related documentation, and (ii) the name of
  8. * Silicon Graphics may not be used in any advertising or
  9. * publicity relating to the software without the specific, prior written
  10. * permission of Silicon Graphics.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
  13. * ANY KIND,
  14. * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  15. * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
  18. * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  19. * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
  21. * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  22. * OF THIS SOFTWARE.
  23. */
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <stdlib.h>
  27. #include <GL/glut.h>
  28. GLenum rgb, doubleBuffer, windType;
  29. int windX, windY;
  30. int cursor;
  31. #include "tkmap.c"
  32. static void Init(void)
  33. {
  34. cursor = 0;
  35. glutSetCursor(cursor);
  36. glClearColor(0.0, 0.0, 0.0, 0.0);
  37. glClearIndex(0.0);
  38. }
  39. static void Reshape(int width, int height)
  40. {
  41. windX = width;
  42. windY = height;
  43. glViewport(0, 0, windX, windY);
  44. glMatrixMode(GL_PROJECTION);
  45. glLoadIdentity();
  46. gluOrtho2D(0, windX, 0, windY);
  47. glMatrixMode(GL_MODELVIEW);
  48. }
  49. static void Key(unsigned char key, int x, int y)
  50. {
  51. switch (key) {
  52. case 27:
  53. exit(1);
  54. case 32:
  55. cursor++;
  56. if (cursor > 19) {
  57. cursor = 0;
  58. }
  59. glutSetCursor(cursor);
  60. }
  61. }
  62. static void Draw(void)
  63. {
  64. glClear(GL_COLOR_BUFFER_BIT);
  65. glBegin(GL_POLYGON);
  66. SetColor(COLOR_BLACK);
  67. glVertex2i(0, 0);
  68. SetColor(COLOR_RED);
  69. glVertex2i(windX, 0);
  70. SetColor(COLOR_GREEN);
  71. glVertex2i(windX, windY);
  72. SetColor(COLOR_BLUE);
  73. glVertex2i(0, windY);
  74. glEnd();
  75. glFlush();
  76. if (doubleBuffer) {
  77. glutSwapBuffers();
  78. }
  79. }
  80. static GLenum Args(int argc, char **argv)
  81. {
  82. GLint i;
  83. rgb = GL_TRUE;
  84. doubleBuffer = GL_FALSE;
  85. for (i = 1; i < argc; i++) {
  86. if (strcmp(argv[i], "-ci") == 0) {
  87. rgb = GL_FALSE;
  88. } else if (strcmp(argv[i], "-rgb") == 0) {
  89. rgb = GL_TRUE;
  90. } else if (strcmp(argv[i], "-sb") == 0) {
  91. doubleBuffer = GL_FALSE;
  92. } else if (strcmp(argv[i], "-db") == 0) {
  93. doubleBuffer = GL_TRUE;
  94. } else {
  95. printf("%s (Bad option).\n", argv[i]);
  96. return GL_FALSE;
  97. }
  98. }
  99. return GL_TRUE;
  100. }
  101. int main(int argc, char **argv)
  102. {
  103. glutInit(&argc, argv);
  104. if (Args(argc, argv) == GL_FALSE) {
  105. exit(1);
  106. }
  107. windX = 300;
  108. windY = 300;
  109. glutInitWindowPosition(0, 0); glutInitWindowSize( windX, windY);
  110. windType = (rgb) ? GLUT_RGB : GLUT_INDEX;
  111. windType |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
  112. glutInitDisplayMode(windType);
  113. if (glutCreateWindow("Cursor Test") == GL_FALSE) {
  114. exit(1);
  115. }
  116. InitMap();
  117. Init();
  118. glutReshapeFunc(Reshape);
  119. glutKeyboardFunc(Key);
  120. glutDisplayFunc(Draw);
  121. glutMainLoop();
  122. return 0;
  123. }