/src/glut-3.7/progs/ada/bezmesh_procs.adb

https://github.com/shadoof/CW2 · Ada · 116 lines · 64 code · 15 blank · 37 comment · 1 complexity · 6fa12e30057c4a51bf562b4652971b66 MD5 · raw file

  1. --
  2. -- (c) Copyright 1993,1994,1995,1996 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(TM) is a trademark of Silicon Graphics, Inc.
  36. --
  37. with GL; use GL;
  38. with Text_IO; use Text_IO;
  39. package body Bezmesh_Procs is
  40. Bezier_Control_Points : array (1 .. 4, 1 .. 4, 1 .. 3) of aliased GLfloat :=
  41. (((-1.5, -1.5, 4.0), (-0.5, -1.5, 2.0),
  42. (0.5, -1.5, -1.0), (1.5, -1.5, 2.0)),
  43. ((-1.5, -0.5, 1.0), (-0.5, -0.5, 3.0),
  44. (0.5, -0.5, 0.0), (1.5, -0.5, -1.0)),
  45. ((-1.5, 0.5, 4.0), (-0.5, 0.5, 0.0),
  46. (0.5, 0.5, 3.0), (1.5, 0.5, 4.0)),
  47. ((-1.5, 1.5, -2.0), (-0.5, 1.5, -2.0),
  48. (0.5, 1.5, 0.0), (1.5, 1.5, -1.0)));
  49. procedure Initialize is
  50. ambient : array (0 .. 3) of aliased GLfloat :=
  51. (0.2, 0.2, 0.2, 1.0);
  52. diffuse : array (0 .. 3) of aliased GLfloat :=
  53. (0.0, 0.0, 2.0, 1.0);
  54. position : array (0 .. 3) of aliased GLfloat :=
  55. (0.6, 0.6, 0.6, 1.0);
  56. mat_diffuse : array (0 .. 3) of aliased GLfloat :=
  57. (0.6, 0.6, 0.6, 1.0);
  58. mat_specular : array (0 .. 3) of aliased GLfloat :=
  59. (1.0, 1.0, 1.0, 1.0);
  60. mat_shininess : aliased GLfloat := 50.0;
  61. begin
  62. glClearColor (0.0, 0.0, 0.0, 1.0);
  63. glEnable (GL_DEPTH_TEST);
  64. glMap2f (GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4,
  65. Bezier_Control_Points(1,1,1)'ACCESS);
  66. glEnable (GL_MAP2_VERTEX_3);
  67. glEnable (GL_AUTO_NORMAL);
  68. glEnable (GL_NORMALIZE);
  69. glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0);
  70. glEnable (GL_LIGHTING);
  71. glEnable (GL_LIGHT0);
  72. glLightfv (GL_LIGHT0, GL_AMBIENT, ambient (0)'access);
  73. glLightfv (GL_LIGHT0, GL_POSITION, position (0)'access);
  74. glMaterialfv (GL_FRONT, GL_DIFFUSE, mat_diffuse (0)'access);
  75. glMaterialfv (GL_FRONT, GL_SPECULAR, mat_specular (0)'access);
  76. glMaterialfv (GL_FRONT, GL_SHININESS, mat_shininess'access);
  77. end Initialize;
  78. procedure Display is
  79. begin
  80. glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  81. glPushMatrix;
  82. -- Glloadidentity;
  83. Glrotatef (85.0, 1.0, 1.0, 1.0);
  84. glEvalMesh2 (GL_FILL, 0, 20, 0, 20);
  85. glPopMatrix;
  86. glFlush;
  87. end Display;
  88. procedure HandleReshape (w : Integer; h : Integer) is
  89. begin
  90. glViewport (0, 0, GLsizei(w), GLsizei(h));
  91. GlMatrixMode (GL_PROJECTION);
  92. GlLoadIdentity;
  93. if (W < H) then
  94. Glortho (-4.0, 4.0, -4.0 * Gldouble (H / W), 4.0 * Gldouble (H / W),
  95. -4.0, 4.0);
  96. else
  97. Glortho (-4.0 * Gldouble (W / H), 4.0 * Gldouble (W / H),
  98. -4.0, 4.0, -4.0, 4.0);
  99. end if;
  100. end HandleReshape;
  101. end Bezmesh_Procs;