opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +2 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +19 -0
  6. data/History.rdoc +26 -0
  7. data/Manifest.txt +3 -23
  8. data/README.rdoc +43 -37
  9. data/Rakefile +6 -62
  10. data/examples/NeHe/nehe_lesson02.rb +3 -2
  11. data/examples/NeHe/nehe_lesson03.rb +3 -2
  12. data/examples/NeHe/nehe_lesson04.rb +3 -1
  13. data/examples/NeHe/nehe_lesson05.rb +4 -1
  14. data/examples/NeHe/nehe_lesson06.rb +9 -6
  15. data/examples/NeHe/nehe_lesson07.rb +9 -6
  16. data/examples/NeHe/nehe_lesson08.rb +9 -6
  17. data/examples/NeHe/nehe_lesson09.rb +10 -6
  18. data/examples/NeHe/nehe_lesson11.rb +9 -6
  19. data/examples/NeHe/nehe_lesson12.rb +9 -6
  20. data/examples/NeHe/nehe_lesson16.rb +50 -47
  21. data/examples/NeHe/nehe_lesson19.rb +10 -7
  22. data/examples/NeHe/nehe_lesson36.rb +234 -229
  23. data/examples/OrangeBook/brick.rb +227 -225
  24. data/examples/OrangeBook/particle.rb +233 -231
  25. data/examples/RedBook/aapoly.rb +71 -70
  26. data/examples/RedBook/aargb.rb +54 -52
  27. data/examples/RedBook/accanti.rb +96 -94
  28. data/examples/RedBook/accpersp.rb +106 -104
  29. data/examples/RedBook/alpha.rb +54 -52
  30. data/examples/RedBook/alpha3D.rb +90 -88
  31. data/examples/RedBook/bezcurve.rb +48 -46
  32. data/examples/RedBook/bezmesh.rb +71 -69
  33. data/examples/RedBook/checker.rb +57 -55
  34. data/examples/RedBook/clip.rb +41 -39
  35. data/examples/RedBook/colormat.rb +72 -70
  36. data/examples/RedBook/cube.rb +39 -37
  37. data/examples/RedBook/depthcue.rb +37 -35
  38. data/examples/RedBook/dof.rb +110 -109
  39. data/examples/RedBook/double.rb +40 -38
  40. data/examples/RedBook/drawf.rb +30 -28
  41. data/examples/RedBook/feedback.rb +79 -77
  42. data/examples/RedBook/fog.rb +90 -89
  43. data/examples/RedBook/font.rb +78 -76
  44. data/examples/RedBook/hello.rb +29 -27
  45. data/examples/RedBook/image.rb +57 -55
  46. data/examples/RedBook/jitter.rb +131 -131
  47. data/examples/RedBook/light.rb +2 -1
  48. data/examples/RedBook/lines.rb +70 -68
  49. data/examples/RedBook/list.rb +48 -46
  50. data/examples/RedBook/material.rb +200 -199
  51. data/examples/RedBook/mipmap.rb +84 -82
  52. data/examples/RedBook/model.rb +55 -53
  53. data/examples/RedBook/movelight.rb +52 -50
  54. data/examples/RedBook/pickdepth.rb +103 -101
  55. data/examples/RedBook/planet.rb +46 -44
  56. data/examples/RedBook/quadric.rb +97 -95
  57. data/examples/RedBook/robot.rb +55 -53
  58. data/examples/RedBook/select.rb +118 -116
  59. data/examples/RedBook/smooth.rb +35 -33
  60. data/examples/RedBook/stencil.rb +96 -94
  61. data/examples/RedBook/stroke.rb +75 -73
  62. data/examples/RedBook/surface.rb +93 -91
  63. data/examples/RedBook/teaambient.rb +71 -69
  64. data/examples/RedBook/teapots.rb +105 -103
  65. data/examples/RedBook/tess.rb +96 -94
  66. data/examples/RedBook/texbind.rb +79 -77
  67. data/examples/RedBook/texgen.rb +88 -86
  68. data/examples/RedBook/texturesurf.rb +57 -55
  69. data/examples/RedBook/varray.rb +85 -83
  70. data/examples/RedBook/wrap.rb +76 -74
  71. data/examples/misc/OGLBench.rb +114 -113
  72. data/examples/misc/anisotropic.rb +154 -152
  73. data/examples/misc/fbo_test.rb +37 -36
  74. data/examples/misc/font-glut.rb +47 -46
  75. data/examples/misc/glfwtest.rb +16 -16
  76. data/examples/misc/plane.rb +13 -13
  77. data/examples/misc/readpixel.rb +66 -65
  78. data/examples/misc/sdltest.rb +21 -19
  79. data/examples/misc/trislam.rb +548 -547
  80. data/ext/opengl/common.h +16 -38
  81. data/ext/opengl/conv.h +39 -41
  82. data/ext/opengl/extconf.rb +4 -31
  83. data/ext/opengl/funcdef.h +126 -124
  84. data/ext/opengl/gl-1.0-1.1.c +1917 -1917
  85. data/ext/opengl/gl-1.2.c +4 -667
  86. data/ext/opengl/gl-1.3.c +9 -9
  87. data/ext/opengl/gl-1.4.c +8 -8
  88. data/ext/opengl/gl-1.5.c +1 -1
  89. data/ext/opengl/gl-2.0.c +392 -388
  90. data/ext/opengl/gl-3.0.c +493 -0
  91. data/ext/opengl/gl-enums.c +1523 -5
  92. data/ext/opengl/gl-enums.h +4679 -122
  93. data/ext/opengl/gl-error.c +7 -7
  94. data/ext/opengl/gl-error.h +4 -4
  95. data/ext/opengl/gl-ext-arb.c +468 -464
  96. data/ext/opengl/gl-ext-ext.c +18 -18
  97. data/ext/opengl/gl-ext-nv.c +15 -15
  98. data/ext/opengl/gl.c +2 -0
  99. data/ext/opengl/gl_buffer.c +92 -92
  100. data/ext/opengl/opengl.c +1 -7
  101. data/lib/opengl.rb +23 -59
  102. data/lib/opengl/1.9/opengl.so +0 -0
  103. data/lib/opengl/2.0/opengl.so +0 -0
  104. data/lib/opengl/2.1/opengl.so +0 -0
  105. data/lib/opengl/test_case.rb +1 -2
  106. data/test/dummy.xorg.conf +140 -0
  107. data/test/test_gl.rb +18 -22
  108. data/test/test_gl_10_11.rb +220 -220
  109. data/test/test_gl_12.rb +11 -122
  110. data/test/test_gl_13.rb +202 -210
  111. data/test/test_gl_14.rb +16 -19
  112. data/test/test_gl_15.rb +2 -4
  113. data/test/test_gl_20.rb +45 -58
  114. data/test/test_gl_21.rb +46 -163
  115. data/test/test_gl_ext_arb.rb +54 -72
  116. data/test/test_gl_ext_ati.rb +0 -2
  117. data/test/test_gl_ext_ext.rb +66 -66
  118. data/test/test_gl_ext_gremedy.rb +8 -15
  119. data/test/test_gl_ext_nv.rb +109 -112
  120. data/test/test_opengl_buffer.rb +8 -25
  121. data/utils/README +0 -5
  122. data/utils/enumgen.rb +72 -76
  123. data/utils/extlistgen.rb +55 -55
  124. metadata +90 -67
  125. metadata.gz.sig +0 -0
  126. data/Rakefile.cross +0 -107
  127. data/docs/build_install.txt +0 -119
  128. data/docs/extensions.txt.in +0 -348
  129. data/docs/history.txt +0 -66
  130. data/docs/requirements_and_design.txt +0 -117
  131. data/docs/roadmap.txt +0 -28
  132. data/docs/scientific_use.txt +0 -35
  133. data/docs/supplies/page_template.html +0 -71
  134. data/docs/thanks.txt +0 -29
  135. data/docs/tutorial.txt +0 -469
  136. data/ext/opengl/glu-enums.c +0 -164
  137. data/ext/opengl/glu-enums.h +0 -463
  138. data/ext/opengl/glu.c +0 -1534
  139. data/ext/opengl/glut.c +0 -1145
  140. data/ext/opengl/glut_callbacks.c +0 -845
  141. data/lib/glu.rb +0 -1
  142. data/lib/glut.rb +0 -1
  143. data/lib/opengl/opengl.so +0 -0
  144. data/test/test_glu.rb +0 -309
  145. data/utils/mkdn2html.rb +0 -59
  146. data/utils/post-mkdn2html.rb +0 -91
  147. data/website/images/ogl.jpg +0 -0
  148. data/website/images/tab_bottom.gif +0 -0
  149. data/website/style.css +0 -198
@@ -2,14 +2,14 @@
2
2
  # Copyright (c) Mark J. Kilgard, 1994. */
3
3
  #
4
4
  # (c) Copyright 1993, Silicon Graphics, Inc.
5
- # ALL RIGHTS RESERVED
6
- # Permission to use, copy, modify, and distribute this software for
5
+ # ALL RIGHTS RESERVED
6
+ # Permission to use, copy, modify, and distribute this software for
7
7
  # any purpose and without fee is hereby granted, provided that the above
8
8
  # copyright notice appear in all copies and that both the copyright notice
9
- # and this permission notice appear in supporting documentation, and that
9
+ # and this permission notice appear in supporting documentation, and that
10
10
  # the name of Silicon Graphics, Inc. not be used in advertising
11
11
  # or publicity pertaining to distribution of the software without specific,
12
- # written prior permission.
12
+ # written prior permission.
13
13
  #
14
14
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
15
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -23,8 +23,8 @@
23
23
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
24
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
25
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
- #
27
- # US Government Users Restricted Rights
26
+ #
27
+ # US Government Users Restricted Rights
28
28
  # Use, duplication, or disclosure by the Government is subject to
29
29
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
30
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -40,22 +40,24 @@
40
40
  # This program uses evaluators to generate a curved
41
41
  # surface and automatically generated texture coordinates.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  $ctrlpoints = [
46
- [[ -1.5, -1.5, 4.0], [ -0.5, -1.5, 2.0], [0.5, -1.5, -1.0], [1.5, -1.5, 2.0]],
47
- [[ -1.5, -0.5, 1.0], [ -0.5, -0.5, 3.0], [0.5, -0.5, 0.0], [1.5, -0.5, -1.0]],
48
- [[ -1.5, 0.5, 4.0], [ -0.5, 0.5, 0.0], [0.5, 0.5, 3.0], [1.5, 0.5, 4.0]],
49
- [[ -1.5, 1.5, -2.0], [ -0.5, 1.5, -2.0], [0.5, 1.5, 0.0], [1.5, 1.5, -1.0]]
48
+ [[ -1.5, -1.5, 4.0], [ -0.5, -1.5, 2.0], [0.5, -1.5, -1.0], [1.5, -1.5, 2.0]],
49
+ [[ -1.5, -0.5, 1.0], [ -0.5, -0.5, 3.0], [0.5, -0.5, 0.0], [1.5, -0.5, -1.0]],
50
+ [[ -1.5, 0.5, 4.0], [ -0.5, 0.5, 0.0], [0.5, 0.5, 3.0], [1.5, 0.5, 4.0]],
51
+ [[ -1.5, 1.5, -2.0], [ -0.5, 1.5, -2.0], [0.5, 1.5, 0.0], [1.5, 1.5, -1.0]]
50
52
  ].flatten
51
53
 
52
54
  $texpts = [[[0.0, 0.0], [0.0, 1.0]], [[1.0, 0.0], [1.0, 1.0]]].flatten
53
55
 
54
56
  display = proc do
55
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
56
- glColor(1.0, 1.0, 1.0)
57
- glEvalMesh2(GL_FILL, 0, 20, 0, 20)
58
- glutSwapBuffers()
57
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
58
+ glColor(1.0, 1.0, 1.0)
59
+ glEvalMesh2(GL_FILL, 0, 20, 0, 20)
60
+ glutSwapBuffers()
59
61
  end
60
62
 
61
63
  ImageWidth=64
@@ -63,57 +65,57 @@ ImageHeight=64
63
65
  $image = []
64
66
 
65
67
  def makeImage
66
- for i in 0...ImageWidth
67
- ti = 2.0*Math::PI*i/ImageWidth.to_f
68
- for j in 0...ImageHeight
69
- tj = 2.0*Math::PI*j/ImageHeight.to_f
68
+ for i in 0...ImageWidth
69
+ ti = 2.0*Math::PI*i/ImageWidth.to_f
70
+ for j in 0...ImageHeight
71
+ tj = 2.0*Math::PI*j/ImageHeight.to_f
70
72
 
71
- $image[3*(ImageHeight*i+j)] = 127*(1.0+Math::sin(ti))
72
- $image[3*(ImageHeight*i+j)+1] = 127*(1.0+Math::cos(2*tj))
73
- $image[3*(ImageHeight*i+j)+2] = 127*(1.0+Math::cos(ti+tj))
74
- end
75
- end
73
+ $image[3*(ImageHeight*i+j)] = 127*(1.0+Math::sin(ti))
74
+ $image[3*(ImageHeight*i+j)+1] = 127*(1.0+Math::cos(2*tj))
75
+ $image[3*(ImageHeight*i+j)+2] = 127*(1.0+Math::cos(ti+tj))
76
+ end
77
+ end
76
78
  end
77
79
 
78
80
  def myinit
79
- glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints)
80
- glMap2d(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, $texpts)
81
- glEnable(GL_MAP2_TEXTURE_COORD_2)
82
- glEnable(GL_MAP2_VERTEX_3)
83
- glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
84
- makeImage()
85
- glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
86
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
87
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
88
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
89
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
90
- glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageWidth, ImageHeight, 0,
91
- GL_RGB, GL_UNSIGNED_BYTE, $image.pack("C*"))
92
- glEnable(GL_TEXTURE_2D)
93
- glEnable(GL_DEPTH_TEST)
94
- glEnable(GL_NORMALIZE)
95
- glShadeModel(GL_FLAT)
81
+ glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints)
82
+ glMap2d(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, $texpts)
83
+ glEnable(GL_MAP2_TEXTURE_COORD_2)
84
+ glEnable(GL_MAP2_VERTEX_3)
85
+ glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
86
+ makeImage()
87
+ glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
88
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
89
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
90
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
91
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
92
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageWidth, ImageHeight, 0,
93
+ GL_RGB, GL_UNSIGNED_BYTE, $image.pack("C*"))
94
+ glEnable(GL_TEXTURE_2D)
95
+ glEnable(GL_DEPTH_TEST)
96
+ glEnable(GL_NORMALIZE)
97
+ glShadeModel(GL_FLAT)
96
98
  end
97
99
 
98
100
  myReshape = proc do|w, h|
99
- glViewport(0, 0, w, h)
100
- glMatrixMode(GL_PROJECTION)
101
- glLoadIdentity()
102
- if (w <= h)
103
- glOrtho(-4.0, 4.0, -4.0*h.to_f/w, 4.0*h.to_f/w, -4.0, 4.0)
104
- else
105
- glOrtho(-4.0*w.to_f/h, 4.0*w.to_f/h, -4.0, 4.0, -4.0, 4.0)
106
- end
107
- glMatrixMode(GL_MODELVIEW)
108
- glLoadIdentity()
109
- glRotate(85.0, 1.0, 1.0, 1.0)
101
+ glViewport(0, 0, w, h)
102
+ glMatrixMode(GL_PROJECTION)
103
+ glLoadIdentity()
104
+ if (w <= h)
105
+ glOrtho(-4.0, 4.0, -4.0*h.to_f/w, 4.0*h.to_f/w, -4.0, 4.0)
106
+ else
107
+ glOrtho(-4.0*w.to_f/h, 4.0*w.to_f/h, -4.0, 4.0, -4.0, 4.0)
108
+ end
109
+ glMatrixMode(GL_MODELVIEW)
110
+ glLoadIdentity()
111
+ glRotate(85.0, 1.0, 1.0, 1.0)
110
112
  end
111
113
 
112
114
  keyboard = Proc.new do |key, x, y|
113
- case (key)
114
- when ?\e
115
- exit(0);
116
- end
115
+ case (key)
116
+ when ?\e
117
+ exit(0);
118
+ end
117
119
  end
118
120
 
119
121
  glutInit()
@@ -1,13 +1,13 @@
1
1
  #
2
2
  # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
5
  # any purpose and without fee is hereby granted, provided that the above
6
6
  # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
7
+ # and this permission notice appear in supporting documentation, and that
8
8
  # the name of Silicon Graphics, Inc. not be used in advertising
9
9
  # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
10
+ # written prior permission.
11
11
  #
12
12
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
13
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -21,8 +21,8 @@
21
21
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
22
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
23
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
24
+ #
25
+ # US Government Users Restricted Rights
26
26
  # Use, duplication, or disclosure by the Government is subject to
27
27
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
28
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -37,6 +37,8 @@
37
37
  # varray.c
38
38
  # This program demonstrates vertex arrays.
39
39
  require 'opengl'
40
+ require 'glu'
41
+ require 'glut'
40
42
  include Gl,Glu,Glut
41
43
 
42
44
  POINTER=1
@@ -50,100 +52,100 @@ $setupMethod = POINTER
50
52
  $derefMethod = DRAWARRAY
51
53
 
52
54
  def setupPointers
53
- $vertices = [25, 25,
54
- 100, 325,
55
- 175, 25,
56
- 175, 325,
57
- 250, 25,
58
- 325, 325].pack("i*")
59
- $colors = [1.0, 0.2, 0.2,
60
- 0.2, 0.2, 1.0,
61
- 0.8, 1.0, 0.2,
62
- 0.75, 0.75, 0.75,
63
- 0.35, 0.35, 0.35,
64
- 0.5, 0.5, 0.5].pack("f*")
65
-
66
- glEnableClientState(GL_VERTEX_ARRAY)
67
- glEnableClientState(GL_COLOR_ARRAY)
68
-
69
- glVertexPointer(2, GL_INT, 0, $vertices)
70
- glColorPointer(3, GL_FLOAT, 0, $colors)
55
+ $vertices = [25, 25,
56
+ 100, 325,
57
+ 175, 25,
58
+ 175, 325,
59
+ 250, 25,
60
+ 325, 325].pack("i*")
61
+ $colors = [1.0, 0.2, 0.2,
62
+ 0.2, 0.2, 1.0,
63
+ 0.8, 1.0, 0.2,
64
+ 0.75, 0.75, 0.75,
65
+ 0.35, 0.35, 0.35,
66
+ 0.5, 0.5, 0.5].pack("f*")
67
+
68
+ glEnableClientState(GL_VERTEX_ARRAY)
69
+ glEnableClientState(GL_COLOR_ARRAY)
70
+
71
+ glVertexPointer(2, GL_INT, 0, $vertices)
72
+ glColorPointer(3, GL_FLOAT, 0, $colors)
71
73
  end
72
74
 
73
75
  def setupInterleave
74
- $intertwined =
75
- [1.0, 0.2, 1.0, 100.0, 100.0, 0.0,
76
- 1.0, 0.2, 0.2, 0.0, 200.0, 0.0,
77
- 1.0, 1.0, 0.2, 100.0, 300.0, 0.0,
78
- 0.2, 1.0, 0.2, 200.0, 300.0, 0.0,
79
- 0.2, 1.0, 1.0, 300.0, 200.0, 0.0,
80
- 0.2, 0.2, 1.0, 200.0, 100.0, 0.0].pack("f*")
81
-
82
- glInterleavedArrays(GL_C3F_V3F, 0, $intertwined)
76
+ $intertwined =
77
+ [1.0, 0.2, 1.0, 100.0, 100.0, 0.0,
78
+ 1.0, 0.2, 0.2, 0.0, 200.0, 0.0,
79
+ 1.0, 1.0, 0.2, 100.0, 300.0, 0.0,
80
+ 0.2, 1.0, 0.2, 200.0, 300.0, 0.0,
81
+ 0.2, 1.0, 1.0, 300.0, 200.0, 0.0,
82
+ 0.2, 0.2, 1.0, 200.0, 100.0, 0.0].pack("f*")
83
+
84
+ glInterleavedArrays(GL_C3F_V3F, 0, $intertwined)
83
85
  end
84
86
 
85
87
  def init
86
- glClearColor(0.0, 0.0, 0.0, 0.0)
87
- glShadeModel(GL_SMOOTH)
88
- setupPointers()
88
+ glClearColor(0.0, 0.0, 0.0, 0.0)
89
+ glShadeModel(GL_SMOOTH)
90
+ setupPointers()
89
91
  end
90
92
 
91
93
  display = proc do
92
- glClear(GL_COLOR_BUFFER_BIT)
93
- if ($derefMethod == DRAWARRAY)
94
- glDrawArrays(GL_TRIANGLES, 0, 6)
95
- elsif ($derefMethod == ARRAYELEMENT)
96
- glBegin(GL_TRIANGLES)
97
- glArrayElement(2)
98
- glArrayElement(3)
99
- glArrayElement(5)
100
- glEnd()
101
- elsif ($derefMethod == DRAWELEMENTS)
102
- $indices = [0, 1, 3, 4].pack("I*")
103
- glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, $indices)
104
- end
105
- glutSwapBuffers()
94
+ glClear(GL_COLOR_BUFFER_BIT)
95
+ if ($derefMethod == DRAWARRAY)
96
+ glDrawArrays(GL_TRIANGLES, 0, 6)
97
+ elsif ($derefMethod == ARRAYELEMENT)
98
+ glBegin(GL_TRIANGLES)
99
+ glArrayElement(2)
100
+ glArrayElement(3)
101
+ glArrayElement(5)
102
+ glEnd()
103
+ elsif ($derefMethod == DRAWELEMENTS)
104
+ $indices = [0, 1, 3, 4].pack("I*")
105
+ glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, $indices)
106
+ end
107
+ glutSwapBuffers()
106
108
  end
107
109
 
108
110
  reshape = proc do|w, h|
109
- glViewport(0, 0, w, h)
110
- glMatrixMode(GL_PROJECTION)
111
- glLoadIdentity()
112
- gluOrtho2D(0.0, w, 0.0, h)
111
+ glViewport(0, 0, w, h)
112
+ glMatrixMode(GL_PROJECTION)
113
+ glLoadIdentity()
114
+ gluOrtho2D(0.0, w, 0.0, h)
113
115
  end
114
116
 
115
117
  mouse = proc do |button, state, x, y|
116
- case (button)
117
- when GLUT_LEFT_BUTTON
118
- if (state == GLUT_DOWN)
119
- if ($setupMethod == POINTER)
120
- $setupMethod = INTERLEAVED
121
- setupInterleave()
122
- elsif ($setupMethod == INTERLEAVED)
123
- $setupMethod = POINTER
124
- setupPointers()
125
- end
126
- glutPostRedisplay()
127
- end
128
- when GLUT_MIDDLE_BUTTON,GLUT_RIGHT_BUTTON
129
- if (state == GLUT_DOWN)
130
- if ($derefMethod == DRAWARRAY)
131
- $derefMethod = ARRAYELEMENT
132
- elsif ($derefMethod == ARRAYELEMENT)
133
- $derefMethod = DRAWELEMENTS
134
- elsif ($derefMethod == DRAWELEMENTS)
135
- $derefMethod = DRAWARRAY
136
- end
137
- glutPostRedisplay()
138
- end
139
- end
118
+ case (button)
119
+ when GLUT_LEFT_BUTTON
120
+ if (state == GLUT_DOWN)
121
+ if ($setupMethod == POINTER)
122
+ $setupMethod = INTERLEAVED
123
+ setupInterleave()
124
+ elsif ($setupMethod == INTERLEAVED)
125
+ $setupMethod = POINTER
126
+ setupPointers()
127
+ end
128
+ glutPostRedisplay()
129
+ end
130
+ when GLUT_MIDDLE_BUTTON,GLUT_RIGHT_BUTTON
131
+ if (state == GLUT_DOWN)
132
+ if ($derefMethod == DRAWARRAY)
133
+ $derefMethod = ARRAYELEMENT
134
+ elsif ($derefMethod == ARRAYELEMENT)
135
+ $derefMethod = DRAWELEMENTS
136
+ elsif ($derefMethod == DRAWELEMENTS)
137
+ $derefMethod = DRAWARRAY
138
+ end
139
+ glutPostRedisplay()
140
+ end
141
+ end
140
142
  end
141
143
 
142
144
  keyboard = proc do |key, x, y|
143
- case (key)
144
- when ?\e
145
- exit(0)
146
- end
145
+ case (key)
146
+ when ?\e
147
+ exit(0)
148
+ end
147
149
  end
148
150
 
149
151
  glutInit()
@@ -152,7 +154,7 @@ glutInitWindowSize(350, 350)
152
154
  glutInitWindowPosition(100, 100)
153
155
  glutCreateWindow()
154
156
  init()
155
- glutDisplayFunc(display)
157
+ glutDisplayFunc(display)
156
158
  glutReshapeFunc(reshape)
157
159
  glutMouseFunc(mouse)
158
160
  glutKeyboardFunc(keyboard)
@@ -1,13 +1,13 @@
1
1
  #
2
2
  # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
5
  # any purpose and without fee is hereby granted, provided that the above
6
6
  # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
7
+ # and this permission notice appear in supporting documentation, and that
8
8
  # the name of Silicon Graphics, Inc. not be used in advertising
9
9
  # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
10
+ # written prior permission.
11
11
  #
12
12
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
13
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -21,8 +21,8 @@
21
21
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
22
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
23
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
24
+ #
25
+ # US Government Users Restricted Rights
26
26
  # Use, duplication, or disclosure by the Government is subject to
27
27
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
28
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -41,14 +41,16 @@
41
41
  # Interaction: Pressing the 's' and 'S' keys switch the
42
42
  # wrapping between clamping and repeating for the s parameter.
43
43
  # The 't' and 'T' keys control the wrapping for the t parameter.
44
- #
44
+ #
45
45
  # If running this program on OpenGL 1.0, texture objects are
46
46
  # not used.
47
47
  require 'opengl'
48
+ require 'glu'
49
+ require 'glut'
48
50
  require 'mathn'
49
51
  include Gl,Glu,Glut
50
52
 
51
- # Create checkerboard texture
53
+ # Create checkerboard texture
52
54
  CheckImageWidth=64
53
55
  CheckImageHeight=64
54
56
  $checkImage = []
@@ -56,84 +58,84 @@ $checkImage = []
56
58
  $texName = 0
57
59
 
58
60
  def makeCheckImage
59
- for i in 0..CheckImageHeight-1
60
- for j in 0..CheckImageWidth-1
61
- c = if (((i&0x8)==0)!=((j&0x8)==0)) then 255 else 0 end
62
- $checkImage[(i*CheckImageWidth+j)*4+0] = c
63
- $checkImage[(i*CheckImageWidth+j)*4+1] = c
64
- $checkImage[(i*CheckImageWidth+j)*4+2] = c
65
- $checkImage[(i*CheckImageWidth+j)*4+3] = 255
66
- end
67
- end
61
+ for i in 0..CheckImageHeight-1
62
+ for j in 0..CheckImageWidth-1
63
+ c = if (((i&0x8)==0)!=((j&0x8)==0)) then 255 else 0 end
64
+ $checkImage[(i*CheckImageWidth+j)*4+0] = c
65
+ $checkImage[(i*CheckImageWidth+j)*4+1] = c
66
+ $checkImage[(i*CheckImageWidth+j)*4+2] = c
67
+ $checkImage[(i*CheckImageWidth+j)*4+3] = 255
68
+ end
69
+ end
68
70
  end
69
71
 
70
72
  def init
71
- glClearColor(0.0, 0.0, 0.0, 0.0)
72
- glShadeModel(GL_FLAT)
73
- glEnable(GL_DEPTH_TEST)
74
-
75
- makeCheckImage()
76
- glPixelStore(GL_UNPACK_ALIGNMENT, 1)
77
-
78
- $texName = glGenTextures(1)
79
- glBindTexture(GL_TEXTURE_2D, $texName[0])
80
-
81
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
82
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
83
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
84
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
85
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth,
86
- CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
73
+ glClearColor(0.0, 0.0, 0.0, 0.0)
74
+ glShadeModel(GL_FLAT)
75
+ glEnable(GL_DEPTH_TEST)
76
+
77
+ makeCheckImage()
78
+ glPixelStore(GL_UNPACK_ALIGNMENT, 1)
79
+
80
+ $texName = glGenTextures(1)
81
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
82
+
83
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
84
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
85
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
86
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
87
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth,
88
+ CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
87
89
  end
88
90
 
89
91
  display = Proc.new do
90
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
91
- glEnable(GL_TEXTURE_2D)
92
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
93
- glBindTexture(GL_TEXTURE_2D, $texName[0])
94
-
95
- glBegin(GL_QUADS)
96
- glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
97
- glTexCoord(0.0, 3.0); glVertex(-2.0, 1.0, 0.0)
98
- glTexCoord(3.0, 3.0); glVertex(0.0, 1.0, 0.0)
99
- glTexCoord(3.0, 0.0); glVertex(0.0, -1.0, 0.0)
100
-
101
- glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
102
- glTexCoord(0.0, 3.0); glVertex(1.0, 1.0, 0.0)
103
- glTexCoord(3.0, 3.0); glVertex(2.41421, 1.0, -1.41421)
104
- glTexCoord(3.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
105
- glEnd()
106
- glutSwapBuffers()
107
- glDisable(GL_TEXTURE_2D)
92
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
93
+ glEnable(GL_TEXTURE_2D)
94
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
95
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
96
+
97
+ glBegin(GL_QUADS)
98
+ glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
99
+ glTexCoord(0.0, 3.0); glVertex(-2.0, 1.0, 0.0)
100
+ glTexCoord(3.0, 3.0); glVertex(0.0, 1.0, 0.0)
101
+ glTexCoord(3.0, 0.0); glVertex(0.0, -1.0, 0.0)
102
+
103
+ glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
104
+ glTexCoord(0.0, 3.0); glVertex(1.0, 1.0, 0.0)
105
+ glTexCoord(3.0, 3.0); glVertex(2.41421, 1.0, -1.41421)
106
+ glTexCoord(3.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
107
+ glEnd()
108
+ glutSwapBuffers()
109
+ glDisable(GL_TEXTURE_2D)
108
110
  end
109
111
 
110
112
  reshape = Proc.new do |w, h|
111
- glViewport(0, 0, w, h)
112
- glMatrixMode(GL_PROJECTION)
113
- glLoadIdentity()
114
- GLU.Perspective(60.0, w/h, 1.0, 30.0)
115
- glMatrixMode(GL_MODELVIEW)
116
- glLoadIdentity()
117
- glTranslate(0.0, 0.0, -3.6)
113
+ glViewport(0, 0, w, h)
114
+ glMatrixMode(GL_PROJECTION)
115
+ glLoadIdentity()
116
+ GLU.Perspective(60.0, w/h, 1.0, 30.0)
117
+ glMatrixMode(GL_MODELVIEW)
118
+ glLoadIdentity()
119
+ glTranslate(0.0, 0.0, -3.6)
118
120
  end
119
121
 
120
122
  keyboard = Proc.new do |key, x, y|
121
- case (key)
122
- when ?s
123
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
124
- glutPostRedisplay()
125
- when ?S
126
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
127
- glutPostRedisplay()
128
- when ?t
129
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
130
- glutPostRedisplay()
131
- when ?T
132
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
133
- glutPostRedisplay()
134
- when ?\e
135
- exit(0)
136
- end
123
+ case (key)
124
+ when ?s
125
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
126
+ glutPostRedisplay()
127
+ when ?S
128
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
129
+ glutPostRedisplay()
130
+ when ?t
131
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
132
+ glutPostRedisplay()
133
+ when ?T
134
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
135
+ glutPostRedisplay()
136
+ when ?\e
137
+ exit(0)
138
+ end
137
139
  end
138
140
 
139
141
  glutInit