Clone of mesa.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (c) 1993-1997, Silicon Graphics, Inc.
  3. * ALL RIGHTS RESERVED
  4. * Permission to use, copy, modify, and distribute this software for
  5. * any purpose and without fee is hereby granted, provided that the above
  6. * copyright notice appear in all copies and that both the copyright notice
  7. * and this permission notice appear in supporting documentation, and that
  8. * the name of Silicon Graphics, Inc. not be used in advertising
  9. * or publicity pertaining to distribution of the software without specific,
  10. * written prior permission.
  11. *
  12. * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13. * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14. * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15. * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
  16. * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17. * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18. * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19. * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20. * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
  21. * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22. * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23. * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24. *
  25. * US Government Users Restricted Rights
  26. * Use, duplication, or disclosure by the Government is subject to
  27. * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28. * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29. * clause at DFARS 252.227-7013 and/or in similar or successor
  30. * clauses in the FAR or the DOD or NASA FAR Supplement.
  31. * Unpublished-- rights reserved under the copyright laws of the
  32. * United States. Contractor/manufacturer is Silicon Graphics,
  33. * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
  34. *
  35. * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
  36. */
  37. /*
  38. * lines.c
  39. * This program demonstrates geometric primitives and
  40. * their attributes.
  41. */
  42. #include <GL/glut.h>
  43. #include <stdlib.h>
  44. #define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \
  45. glVertex2f ((x1),(y1)); glVertex2f ((x2),(y2)); glEnd();
  46. void init(void)
  47. {
  48. glClearColor (0.0, 0.0, 0.0, 0.0);
  49. glShadeModel (GL_FLAT);
  50. }
  51. void display(void)
  52. {
  53. int i;
  54. glClear (GL_COLOR_BUFFER_BIT);
  55. /* select white for all lines */
  56. glColor3f (1.0, 1.0, 1.0);
  57. /* in 1st row, 3 lines, each with a different stipple */
  58. glEnable (GL_LINE_STIPPLE);
  59. glLineStipple (1, 0x0101); /* dotted */
  60. drawOneLine (50.0, 125.0, 150.0, 125.0);
  61. glLineStipple (1, 0x00FF); /* dashed */
  62. drawOneLine (150.0, 125.0, 250.0, 125.0);
  63. glLineStipple (1, 0x1C47); /* dash/dot/dash */
  64. drawOneLine (250.0, 125.0, 350.0, 125.0);
  65. /* in 2nd row, 3 wide lines, each with different stipple */
  66. glLineWidth (5.0);
  67. glLineStipple (1, 0x0101); /* dotted */
  68. drawOneLine (50.0, 100.0, 150.0, 100.0);
  69. glLineStipple (1, 0x00FF); /* dashed */
  70. drawOneLine (150.0, 100.0, 250.0, 100.0);
  71. glLineStipple (1, 0x1C47); /* dash/dot/dash */
  72. drawOneLine (250.0, 100.0, 350.0, 100.0);
  73. glLineWidth (1.0);
  74. /* in 3rd row, 6 lines, with dash/dot/dash stipple */
  75. /* as part of a single connected line strip */
  76. glLineStipple (1, 0x1C47); /* dash/dot/dash */
  77. glBegin (GL_LINE_STRIP);
  78. for (i = 0; i < 7; i++)
  79. glVertex2f (50.0 + ((GLfloat) i * 50.0), 75.0);
  80. glEnd ();
  81. /* in 4th row, 6 independent lines with same stipple */
  82. for (i = 0; i < 6; i++) {
  83. drawOneLine (50.0 + ((GLfloat) i * 50.0), 50.0,
  84. 50.0 + ((GLfloat)(i+1) * 50.0), 50.0);
  85. }
  86. /* in 5th row, 1 line, with dash/dot/dash stipple */
  87. /* and a stipple repeat factor of 5 */
  88. glLineStipple (5, 0x1C47); /* dash/dot/dash */
  89. drawOneLine (50.0, 25.0, 350.0, 25.0);
  90. glDisable (GL_LINE_STIPPLE);
  91. glFlush ();
  92. }
  93. void reshape (int w, int h)
  94. {
  95. glViewport (0, 0, (GLsizei) w, (GLsizei) h);
  96. glMatrixMode (GL_PROJECTION);
  97. glLoadIdentity ();
  98. gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h);
  99. }
  100. /* ARGSUSED1 */
  101. void keyboard(unsigned char key, int x, int y)
  102. {
  103. switch (key) {
  104. case 27:
  105. exit(0);
  106. break;
  107. }
  108. }
  109. int main(int argc, char** argv)
  110. {
  111. glutInit(&argc, argv);
  112. glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  113. glutInitWindowSize (400, 150);
  114. glutInitWindowPosition (100, 100);
  115. glutCreateWindow (argv[0]);
  116. init ();
  117. glutDisplayFunc(display);
  118. glutReshapeFunc(reshape);
  119. glutKeyboardFunc(keyboard);
  120. glutMainLoop();
  121. return 0;
  122. }