opengl 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +0 -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/test_case.rb +1 -2
  103. data/test/dummy.xorg.conf +140 -0
  104. data/test/test_gl.rb +18 -22
  105. data/test/test_gl_10_11.rb +220 -220
  106. data/test/test_gl_12.rb +11 -122
  107. data/test/test_gl_13.rb +202 -210
  108. data/test/test_gl_14.rb +16 -19
  109. data/test/test_gl_15.rb +2 -4
  110. data/test/test_gl_20.rb +45 -58
  111. data/test/test_gl_21.rb +46 -163
  112. data/test/test_gl_ext_arb.rb +54 -72
  113. data/test/test_gl_ext_ati.rb +0 -2
  114. data/test/test_gl_ext_ext.rb +66 -66
  115. data/test/test_gl_ext_gremedy.rb +8 -15
  116. data/test/test_gl_ext_nv.rb +109 -112
  117. data/test/test_opengl_buffer.rb +8 -25
  118. data/utils/README +0 -5
  119. data/utils/enumgen.rb +72 -76
  120. data/utils/extlistgen.rb +55 -55
  121. metadata +87 -66
  122. metadata.gz.sig +2 -0
  123. data/Rakefile.cross +0 -107
  124. data/docs/build_install.txt +0 -119
  125. data/docs/extensions.txt.in +0 -348
  126. data/docs/history.txt +0 -66
  127. data/docs/requirements_and_design.txt +0 -117
  128. data/docs/roadmap.txt +0 -28
  129. data/docs/scientific_use.txt +0 -35
  130. data/docs/supplies/page_template.html +0 -71
  131. data/docs/thanks.txt +0 -29
  132. data/docs/tutorial.txt +0 -469
  133. data/ext/opengl/glu-enums.c +0 -164
  134. data/ext/opengl/glu-enums.h +0 -463
  135. data/ext/opengl/glu.c +0 -1534
  136. data/ext/opengl/glut.c +0 -1145
  137. data/ext/opengl/glut_callbacks.c +0 -845
  138. data/lib/glu.rb +0 -1
  139. data/lib/glut.rb +0 -1
  140. data/test/test_glu.rb +0 -309
  141. data/utils/mkdn2html.rb +0 -59
  142. data/utils/post-mkdn2html.rb +0 -91
  143. data/website/images/ogl.jpg +0 -0
  144. data/website/images/tab_bottom.gif +0 -0
  145. 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
@@ -43,6 +43,8 @@
43
43
  # Thus, the quadrilateral which is drawn is drawn with several
44
44
  # different colors.
45
45
  require 'opengl'
46
+ require 'glu'
47
+ require 'glut'
46
48
  require 'mathn'
47
49
  include Gl,Glu,Glut
48
50
 
@@ -54,94 +56,94 @@ $mipmapImage2 = []
54
56
  $mipmapImage1 = []
55
57
 
56
58
  def makeImages
57
- for i in 0..31
58
- for j in 0..31
59
- $mipmapImage32[(j*32+i)*3+0] = 255
60
- $mipmapImage32[(j*32+i)*3+1] = 255
61
- $mipmapImage32[(j*32+i)*3+2] = 0
62
- end
63
- end
64
- for i in 0..15
65
- for j in 0..15
66
- $mipmapImage16[(j*16+i)*3+0] = 255
67
- $mipmapImage16[(j*16+i)*3+1] = 0
68
- $mipmapImage16[(j*16+i)*3+2] = 255
69
- end
70
- end
71
- for i in 0..7
72
- for j in 0..7
73
- $mipmapImage8[(j*8+i)*3+0] = 255
74
- $mipmapImage8[(j*8+i)*3+1] = 0
75
- $mipmapImage8[(j*8+i)*3+2] = 0
76
- end
77
- end
78
- for i in 0..3
79
- for j in 0..3
80
- $mipmapImage4[(j*4+i)*3+0] = 0
81
- $mipmapImage4[(j*4+i)*3+1] = 255
82
- $mipmapImage4[(j*4+i)*3+2] = 0
83
- end
84
- end
85
- for i in 0..1
86
- for j in 0..1
87
- $mipmapImage2[(j*2+i)*3+0] = 0
88
- $mipmapImage2[(j*2+i)*3+1] = 0
89
- $mipmapImage2[(j*2+i)*3+2] = 255
90
- end
91
- end
92
- $mipmapImage1[0] = 255
93
- $mipmapImage1[1] = 255
94
- $mipmapImage1[2] = 255
59
+ for i in 0..31
60
+ for j in 0..31
61
+ $mipmapImage32[(j*32+i)*3+0] = 255
62
+ $mipmapImage32[(j*32+i)*3+1] = 255
63
+ $mipmapImage32[(j*32+i)*3+2] = 0
64
+ end
65
+ end
66
+ for i in 0..15
67
+ for j in 0..15
68
+ $mipmapImage16[(j*16+i)*3+0] = 255
69
+ $mipmapImage16[(j*16+i)*3+1] = 0
70
+ $mipmapImage16[(j*16+i)*3+2] = 255
71
+ end
72
+ end
73
+ for i in 0..7
74
+ for j in 0..7
75
+ $mipmapImage8[(j*8+i)*3+0] = 255
76
+ $mipmapImage8[(j*8+i)*3+1] = 0
77
+ $mipmapImage8[(j*8+i)*3+2] = 0
78
+ end
79
+ end
80
+ for i in 0..3
81
+ for j in 0..3
82
+ $mipmapImage4[(j*4+i)*3+0] = 0
83
+ $mipmapImage4[(j*4+i)*3+1] = 255
84
+ $mipmapImage4[(j*4+i)*3+2] = 0
85
+ end
86
+ end
87
+ for i in 0..1
88
+ for j in 0..1
89
+ $mipmapImage2[(j*2+i)*3+0] = 0
90
+ $mipmapImage2[(j*2+i)*3+1] = 0
91
+ $mipmapImage2[(j*2+i)*3+2] = 255
92
+ end
93
+ end
94
+ $mipmapImage1[0] = 255
95
+ $mipmapImage1[1] = 255
96
+ $mipmapImage1[2] = 255
95
97
  end
96
98
 
97
99
  def myinit
98
- glEnable(GL_DEPTH_TEST)
99
- glDepthFunc(GL_LESS)
100
- glShadeModel(GL_FLAT)
101
-
102
- glTranslate(0.0, 0.0, -3.6)
103
- makeImages()
104
- glPixelStore(GL_UNPACK_ALIGNMENT, 1)
105
- glTexImage2D(GL_TEXTURE_2D, 0, 3, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage32.pack("C*"))
106
- glTexImage2D(GL_TEXTURE_2D, 1, 3, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage16.pack("C*"))
107
- glTexImage2D(GL_TEXTURE_2D, 2, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage8.pack("C*"))
108
- glTexImage2D(GL_TEXTURE_2D, 3, 3, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage4.pack("C*"))
109
- glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage2.pack("C*"))
110
- glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage1.pack("C*"))
111
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
112
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
113
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
114
- glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
115
- GL_NEAREST_MIPMAP_NEAREST)
116
- glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
117
- glEnable(GL_TEXTURE_2D)
100
+ glEnable(GL_DEPTH_TEST)
101
+ glDepthFunc(GL_LESS)
102
+ glShadeModel(GL_FLAT)
103
+
104
+ glTranslate(0.0, 0.0, -3.6)
105
+ makeImages()
106
+ glPixelStore(GL_UNPACK_ALIGNMENT, 1)
107
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage32.pack("C*"))
108
+ glTexImage2D(GL_TEXTURE_2D, 1, 3, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage16.pack("C*"))
109
+ glTexImage2D(GL_TEXTURE_2D, 2, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage8.pack("C*"))
110
+ glTexImage2D(GL_TEXTURE_2D, 3, 3, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage4.pack("C*"))
111
+ glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage2.pack("C*"))
112
+ glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage1.pack("C*"))
113
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
114
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
115
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
116
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
117
+ GL_NEAREST_MIPMAP_NEAREST)
118
+ glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
119
+ glEnable(GL_TEXTURE_2D)
118
120
  end
119
121
 
120
122
  display = Proc.new do
121
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
122
- glBegin(GL_QUADS)
123
- glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
124
- glTexCoord(0.0, 8.0); glVertex(-2.0, 1.0, 0.0)
125
- glTexCoord(8.0, 8.0); glVertex(2000.0, 1.0, -6000.0)
126
- glTexCoord(8.0, 0.0); glVertex(2000.0, -1.0, -6000.0)
127
- glEnd()
128
- glutSwapBuffers()
123
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
124
+ glBegin(GL_QUADS)
125
+ glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
126
+ glTexCoord(0.0, 8.0); glVertex(-2.0, 1.0, 0.0)
127
+ glTexCoord(8.0, 8.0); glVertex(2000.0, 1.0, -6000.0)
128
+ glTexCoord(8.0, 0.0); glVertex(2000.0, -1.0, -6000.0)
129
+ glEnd()
130
+ glutSwapBuffers()
129
131
  end
130
132
 
131
133
  myReshape = Proc.new do |w, h|
132
- glViewport(0, 0, w, h)
133
- glMatrixMode(GL_PROJECTION)
134
- glLoadIdentity()
135
- gluPerspective(60.0, 1.0*w/h, 1.0, 30000.0)
136
- glMatrixMode(GL_MODELVIEW)
137
- glLoadIdentity()
134
+ glViewport(0, 0, w, h)
135
+ glMatrixMode(GL_PROJECTION)
136
+ glLoadIdentity()
137
+ gluPerspective(60.0, 1.0*w/h, 1.0, 30000.0)
138
+ glMatrixMode(GL_MODELVIEW)
139
+ glLoadIdentity()
138
140
  end
139
141
 
140
142
  keyboard = Proc.new do |key, x, y|
141
- case (key)
142
- when ?\e
143
- exit(0);
144
- end
143
+ case (key)
144
+ when ?\e
145
+ exit(0);
146
+ end
145
147
  end
146
148
 
147
149
  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,77 +37,79 @@
37
37
  # model.c
38
38
  # This program demonstrates modeling transformations
39
39
  require 'opengl'
40
+ require 'glu'
41
+ require 'glut'
40
42
  require 'mathn'
41
43
  include Gl,Glu,Glut
42
44
 
43
45
  def init
44
- glClearColor(0.0, 0.0, 0.0, 0.0)
45
- glShadeModel(GL_FLAT)
46
+ glClearColor(0.0, 0.0, 0.0, 0.0)
47
+ glShadeModel(GL_FLAT)
46
48
  end
47
49
 
48
50
  def draw_triangle
49
- glBegin(GL_LINE_LOOP)
50
- glVertex(0.0, 25.0)
51
- glVertex(25.0, -25.0)
52
- glVertex(-25.0, -25.0)
53
- glEnd()
51
+ glBegin(GL_LINE_LOOP)
52
+ glVertex(0.0, 25.0)
53
+ glVertex(25.0, -25.0)
54
+ glVertex(-25.0, -25.0)
55
+ glEnd()
54
56
  end
55
57
 
56
58
  display = Proc.new do
57
- glClear(GL_COLOR_BUFFER_BIT)
58
- glColor(1.0, 1.0, 1.0)
59
-
60
- glLoadIdentity()
61
- glColor(1.0, 1.0, 1.0)
62
- draw_triangle()
63
-
64
- glEnable(GL_LINE_STIPPLE)
65
- glLineStipple(1, 0xF0F0)
66
- glLoadIdentity()
67
- glTranslate(-20.0, 0.0, 0.0)
68
- draw_triangle()
69
-
70
- glLineStipple(1, 0xF00F)
71
- glLoadIdentity()
72
- glScale(1.5, 0.5, 1.0)
73
- draw_triangle()
74
-
75
- glLineStipple(1, 0x8888)
76
- glLoadIdentity()
77
- glRotate(90.0, 0.0, 0.0, 1.0)
78
- draw_triangle()
79
- glDisable(GL_LINE_STIPPLE)
80
-
81
- glutSwapBuffers()
59
+ glClear(GL_COLOR_BUFFER_BIT)
60
+ glColor(1.0, 1.0, 1.0)
61
+
62
+ glLoadIdentity()
63
+ glColor(1.0, 1.0, 1.0)
64
+ draw_triangle()
65
+
66
+ glEnable(GL_LINE_STIPPLE)
67
+ glLineStipple(1, 0xF0F0)
68
+ glLoadIdentity()
69
+ glTranslate(-20.0, 0.0, 0.0)
70
+ draw_triangle()
71
+
72
+ glLineStipple(1, 0xF00F)
73
+ glLoadIdentity()
74
+ glScale(1.5, 0.5, 1.0)
75
+ draw_triangle()
76
+
77
+ glLineStipple(1, 0x8888)
78
+ glLoadIdentity()
79
+ glRotate(90.0, 0.0, 0.0, 1.0)
80
+ draw_triangle()
81
+ glDisable(GL_LINE_STIPPLE)
82
+
83
+ glutSwapBuffers()
82
84
  end
83
85
 
84
86
  reshape = Proc.new do |w, h|
85
- glViewport(0, 0, w, h)
86
- glMatrixMode(GL_PROJECTION)
87
- glLoadIdentity()
88
- if (w <= h)
89
- glOrtho(-50.0, 50.0, -50.0*h/w, 50.0*h/w, -1.0, 1.0)
90
- else
91
- glOrtho(-50.0*w/h,50.0*w/h, -50.0, 50.0, -1.0, 1.0)
92
- end
93
- glMatrixMode(GL_MODELVIEW)
87
+ glViewport(0, 0, w, h)
88
+ glMatrixMode(GL_PROJECTION)
89
+ glLoadIdentity()
90
+ if (w <= h)
91
+ glOrtho(-50.0, 50.0, -50.0*h/w, 50.0*h/w, -1.0, 1.0)
92
+ else
93
+ glOrtho(-50.0*w/h,50.0*w/h, -50.0, 50.0, -1.0, 1.0)
94
+ end
95
+ glMatrixMode(GL_MODELVIEW)
94
96
  end
95
97
 
96
98
  keyboard = Proc.new do |key, x, y|
97
- case key
98
- when ?\e
99
- exit(0)
100
- end
99
+ case key
100
+ when ?\e
101
+ exit(0)
102
+ end
101
103
  end
102
104
 
103
105
  # main
104
106
  glutInit()
105
107
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
106
- glutInitWindowSize(500, 500)
108
+ glutInitWindowSize(500, 500)
107
109
  glutInitWindowPosition(100, 100)
108
110
  glutCreateWindow($0)
109
111
  init()
110
- glutDisplayFunc(display)
112
+ glutDisplayFunc(display)
111
113
  glutReshapeFunc(reshape)
112
114
  glutKeyboardFunc(keyboard)
113
115
  glutMainLoop()
@@ -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
@@ -49,6 +49,8 @@
49
49
  # The scene is then redrawn with the light in a new position.
50
50
 
51
51
  require 'opengl'
52
+ require 'glu'
53
+ require 'glut'
52
54
  require 'rational'
53
55
  require 'mathn'
54
56
  include Gl,Glu,Glut
@@ -58,11 +60,11 @@ $spin = 0
58
60
  # Initialize material property, light source, lighting model,
59
61
  # and depth buffer.
60
62
  def init
61
- glClearColor(0.0, 0.0, 0.0, 0.0)
62
- glShadeModel(GL_SMOOTH)
63
- glEnable(GL_LIGHTING)
64
- glEnable(GL_LIGHT0)
65
- glEnable(GL_DEPTH_TEST)
63
+ glClearColor(0.0, 0.0, 0.0, 0.0)
64
+ glShadeModel(GL_SMOOTH)
65
+ glEnable(GL_LIGHTING)
66
+ glEnable(GL_LIGHT0)
67
+ glEnable(GL_DEPTH_TEST)
66
68
  end
67
69
 
68
70
  # Here is where the light position is reset after the modeling
@@ -70,62 +72,62 @@ end
70
72
  # light at a new position in world coordinates. The cube
71
73
  # represents the position of the light.
72
74
  display = Proc.new do
73
- position = [ 0.0, 0.0, 1.5, 1.0 ]
74
-
75
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
76
- glPushMatrix()
77
- GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
78
-
79
- glPushMatrix()
80
- glRotate($spin, 1.0, 0.0, 0.0)
81
- glLight(GL_LIGHT0, GL_POSITION, position)
82
-
83
- glTranslate(0.0, 0.0, 1.5)
84
- glDisable(GL_LIGHTING)
85
- glColor(0.0, 1.0, 1.0)
86
- glutWireCube(0.1)
87
- glEnable(GL_LIGHTING)
88
- glPopMatrix()
89
-
90
- glutSolidTorus(0.275, 0.85, 8, 15)
91
- glPopMatrix()
92
- glutSwapBuffers()
75
+ position = [ 0.0, 0.0, 1.5, 1.0 ]
76
+
77
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
78
+ glPushMatrix()
79
+ GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
80
+
81
+ glPushMatrix()
82
+ glRotate($spin, 1.0, 0.0, 0.0)
83
+ glLight(GL_LIGHT0, GL_POSITION, position)
84
+
85
+ glTranslate(0.0, 0.0, 1.5)
86
+ glDisable(GL_LIGHTING)
87
+ glColor(0.0, 1.0, 1.0)
88
+ glutWireCube(0.1)
89
+ glEnable(GL_LIGHTING)
90
+ glPopMatrix()
91
+
92
+ glutSolidTorus(0.275, 0.85, 8, 15)
93
+ glPopMatrix()
94
+ glutSwapBuffers()
93
95
  end
94
96
 
95
97
  reshape = Proc.new do |w, h|
96
- glViewport(0, 0, w, h)
97
- glMatrixMode(GL_PROJECTION)
98
- glLoadIdentity()
99
- gluPerspective(40.0, w/h, 1.0, 20.0)
100
- glMatrixMode(GL_MODELVIEW)
101
- glLoadIdentity()
98
+ glViewport(0, 0, w, h)
99
+ glMatrixMode(GL_PROJECTION)
100
+ glLoadIdentity()
101
+ gluPerspective(40.0, w/h, 1.0, 20.0)
102
+ glMatrixMode(GL_MODELVIEW)
103
+ glLoadIdentity()
102
104
  end
103
105
 
104
106
  mouse = Proc.new do |button, state, x, y|
105
- case button
106
- when GLUT_LEFT_BUTTON
107
- if (state == GLUT_DOWN)
108
- $spin = ($spin + 30) % 360
109
- glutPostRedisplay()
110
- end
111
- end
107
+ case button
108
+ when GLUT_LEFT_BUTTON
109
+ if (state == GLUT_DOWN)
110
+ $spin = ($spin + 30) % 360
111
+ glutPostRedisplay()
112
+ end
113
+ end
112
114
  end
113
115
 
114
116
  keyboard = Proc.new do |key, x, y|
115
- case key
116
- when ?\e
117
- exit(0)
118
- end
117
+ case key
118
+ when ?\e
119
+ exit(0)
120
+ end
119
121
  end
120
122
 
121
123
  # main
122
124
  glutInit
123
125
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
124
- glutInitWindowSize(500, 500)
126
+ glutInitWindowSize(500, 500)
125
127
  glutInitWindowPosition(100, 100)
126
128
  glutCreateWindow($0)
127
129
  init()
128
- glutDisplayFunc(display)
130
+ glutDisplayFunc(display)
129
131
  glutReshapeFunc(reshape)
130
132
  glutMouseFunc(mouse)
131
133
  glutKeyboardFunc(keyboard)