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
@@ -3,14 +3,14 @@
3
3
  #
4
4
  #
5
5
  # (c) Copyright 1993, Silicon Graphics, Inc.
6
- # ALL RIGHTS RESERVED
7
- # Permission to use, copy, modify, and distribute this software for
6
+ # ALL RIGHTS RESERVED
7
+ # Permission to use, copy, modify, and distribute this software for
8
8
  # any purpose and without fee is hereby granted, provided that the above
9
9
  # copyright notice appear in all copies and that both the copyright notice
10
- # and this permission notice appear in supporting documentation, and that
10
+ # and this permission notice appear in supporting documentation, and that
11
11
  # the name of Silicon Graphics, Inc. not be used in advertising
12
12
  # or publicity pertaining to distribution of the software without specific,
13
- # written prior permission.
13
+ # written prior permission.
14
14
  #
15
15
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
16
16
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -24,8 +24,8 @@
24
24
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25
25
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26
26
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
27
- #
28
- # US Government Users Restricted Rights
27
+ #
28
+ # US Government Users Restricted Rights
29
29
  # Use, duplication, or disclosure by the Government is subject to
30
30
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
31
31
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -38,133 +38,135 @@
38
38
  # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
39
39
  #
40
40
  # pickdepth.c
41
- # Picking is demonstrated in this program. In
42
- # rendering mode, three overlapping rectangles are
43
- # drawn. When the left mouse button is pressed,
44
- # selection mode is entered with the picking matrix.
41
+ # Picking is demonstrated in this program. In
42
+ # rendering mode, three overlapping rectangles are
43
+ # drawn. When the left mouse button is pressed,
44
+ # selection mode is entered with the picking matrix.
45
45
  # Rectangles which are drawn under the cursor position
46
- # are "picked." Pay special attention to the depth
46
+ # are "picked." Pay special attention to the depth
47
47
  # value range, which is returned.
48
48
  require 'opengl'
49
+ require 'glu'
50
+ require 'glut'
49
51
  include Gl,Glu,Glut
50
52
 
51
53
  def myinit
52
- glClearColor(0.0, 0.0, 0.0, 0.0)
53
- glDepthFunc(GL_LESS)
54
- glEnable(GL_DEPTH_TEST)
55
- glShadeModel(GL_FLAT)
56
- glDepthRange(0.0, 1.0) #/* The default z mapping */
54
+ glClearColor(0.0, 0.0, 0.0, 0.0)
55
+ glDepthFunc(GL_LESS)
56
+ glEnable(GL_DEPTH_TEST)
57
+ glShadeModel(GL_FLAT)
58
+ glDepthRange(0.0, 1.0) #/* The default z mapping */
57
59
  end
58
60
 
59
- # The three rectangles are drawn. In selection mode,
60
- # each rectangle is given the same name. Note that
61
+ # The three rectangles are drawn. In selection mode,
62
+ # each rectangle is given the same name. Note that
61
63
  # each rectangle is drawn with a different z value.
62
64
  def drawRects(mode)
63
- if (mode == GL_SELECT)
64
- glLoadName(1)
65
- end
66
- glBegin(GL_QUADS)
67
- glColor(1.0, 1.0, 0.0)
68
- glVertex(2, 0, 0)
69
- glVertex(2, 6, 0)
70
- glVertex(6, 6, 0)
71
- glVertex(6, 0, 0)
72
- glEnd()
73
- if (mode == GL_SELECT)
74
- glLoadName(2)
75
- end
76
- glBegin(GL_QUADS)
77
- glColor(0.0, 1.0, 1.0)
78
- glVertex(3, 2, -1)
79
- glVertex(3, 8, -1)
80
- glVertex(8, 8, -1)
81
- glVertex(8, 2, -1)
82
- glEnd()
83
- if (mode == GL_SELECT)
84
- glLoadName(3)
85
- end
86
- glBegin(GL_QUADS)
87
- glColor(1.0, 0.0, 1.0)
88
- glVertex(0, 2, -2)
89
- glVertex(0, 7, -2)
90
- glVertex(5, 7, -2)
91
- glVertex(5, 2, -2)
92
- glEnd()
65
+ if (mode == GL_SELECT)
66
+ glLoadName(1)
67
+ end
68
+ glBegin(GL_QUADS)
69
+ glColor(1.0, 1.0, 0.0)
70
+ glVertex(2, 0, 0)
71
+ glVertex(2, 6, 0)
72
+ glVertex(6, 6, 0)
73
+ glVertex(6, 0, 0)
74
+ glEnd()
75
+ if (mode == GL_SELECT)
76
+ glLoadName(2)
77
+ end
78
+ glBegin(GL_QUADS)
79
+ glColor(0.0, 1.0, 1.0)
80
+ glVertex(3, 2, -1)
81
+ glVertex(3, 8, -1)
82
+ glVertex(8, 8, -1)
83
+ glVertex(8, 2, -1)
84
+ glEnd()
85
+ if (mode == GL_SELECT)
86
+ glLoadName(3)
87
+ end
88
+ glBegin(GL_QUADS)
89
+ glColor(1.0, 0.0, 1.0)
90
+ glVertex(0, 2, -2)
91
+ glVertex(0, 7, -2)
92
+ glVertex(5, 7, -2)
93
+ glVertex(5, 2, -2)
94
+ glEnd()
93
95
  end
94
96
 
95
- # processHits() prints out the contents of the
97
+ # processHits() prints out the contents of the
96
98
  # selection array.
97
99
  def processHits(hits, buffer)
98
- printf("hits = %d\n", hits)
99
- ptr = buffer.unpack("I*")
100
- p = 0
101
- for i in 0...hits # for each hit
102
- names = ptr[p]
103
- printf(" number of names for hit = %d\n", names); p+=1
104
- printf(" z1 is %g", ptr[p].to_f/0xffffffff); p+=1
105
- printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1
106
- printf(" the name is ")
107
- for j in 0...names # for each name
108
- printf("%d ", ptr[p]) ; p+=1
109
- end
110
- printf("\n")
111
- end
100
+ printf("hits = %d\n", hits)
101
+ ptr = buffer.unpack("I*")
102
+ p = 0
103
+ for i in 0...hits # for each hit
104
+ names = ptr[p]
105
+ printf(" number of names for hit = %d\n", names); p+=1
106
+ printf(" z1 is %g", ptr[p].to_f/0xffffffff); p+=1
107
+ printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1
108
+ printf(" the name is ")
109
+ for j in 0...names # for each name
110
+ printf("%d ", ptr[p]) ; p+=1
111
+ end
112
+ printf("\n")
113
+ end
112
114
  end
113
115
 
114
- # pickRects() sets up selection mode, name stack,
115
- # and projection matrix for picking. Then the objects
116
+ # pickRects() sets up selection mode, name stack,
117
+ # and projection matrix for picking. Then the objects
116
118
  # are drawn.
117
119
  BUFSIZE=512
118
120
 
119
121
  pickRects = proc do |button, state, x, y|
120
- if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
121
- viewport = glGetDoublev(GL_VIEWPORT)
122
-
123
- selectBuf = glSelectBuffer(BUFSIZE)
124
- glRenderMode(GL_SELECT)
125
-
126
- glInitNames()
127
- glPushName(~0)
128
-
129
- glMatrixMode(GL_PROJECTION)
130
- glPushMatrix()
131
- glLoadIdentity()
132
- # create 5x5 pixel picking region near cursor location
133
- gluPickMatrix( x, viewport[3] - y, 5.0, 5.0, viewport)
134
- glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
135
- drawRects(GL_SELECT)
136
- glPopMatrix()
137
- glFlush()
138
-
139
- hits = glRenderMode(GL_RENDER)
140
- processHits(hits, selectBuf)
141
- end
122
+ if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
123
+ viewport = glGetDoublev(GL_VIEWPORT)
124
+
125
+ selectBuf = glSelectBuffer(BUFSIZE)
126
+ glRenderMode(GL_SELECT)
127
+
128
+ glInitNames()
129
+ glPushName(~0)
130
+
131
+ glMatrixMode(GL_PROJECTION)
132
+ glPushMatrix()
133
+ glLoadIdentity()
134
+ # create 5x5 pixel picking region near cursor location
135
+ gluPickMatrix( x, viewport[3] - y, 5.0, 5.0, viewport)
136
+ glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
137
+ drawRects(GL_SELECT)
138
+ glPopMatrix()
139
+ glFlush()
140
+
141
+ hits = glRenderMode(GL_RENDER)
142
+ processHits(hits, selectBuf)
143
+ end
142
144
  end
143
145
 
144
146
  display = proc do
145
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
146
- drawRects(GL_RENDER)
147
- glutSwapBuffers()
147
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
148
+ drawRects(GL_RENDER)
149
+ glutSwapBuffers()
148
150
  end
149
151
 
150
152
  myReshape = proc do |w, h|
151
- glViewport(0, 0, w, h)
152
- glMatrixMode(GL_PROJECTION)
153
- glLoadIdentity()
154
- glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
155
- glMatrixMode(GL_MODELVIEW)
156
- glLoadIdentity()
153
+ glViewport(0, 0, w, h)
154
+ glMatrixMode(GL_PROJECTION)
155
+ glLoadIdentity()
156
+ glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
157
+ glMatrixMode(GL_MODELVIEW)
158
+ glLoadIdentity()
157
159
  end
158
160
 
159
161
  keyboard = Proc.new do |key, x, y|
160
- case (key)
161
- when ?\e
162
- exit(0)
163
- end
162
+ case (key)
163
+ when ?\e
164
+ exit(0)
165
+ end
164
166
  end
165
167
 
166
168
  # Main Loop
167
- # Open window with initial window size, title bar,
169
+ # Open window with initial window size, title bar,
168
170
  # RGBA display mode, depth buffer, and handle input events.
169
171
  glutInitWindowSize(500, 500)
170
172
  glutInitWindowPosition(100, 100)
@@ -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
@@ -40,6 +40,8 @@
40
40
  # Interaction: pressing the d and y keys (day and year)
41
41
  # alters the rotation of the planet around the sun.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  require 'rational'
44
46
  include Gl,Glu,Glut
45
47
 
@@ -49,60 +51,60 @@ $year = 0
49
51
  $day = 0
50
52
 
51
53
  def init
52
- glClearColor(0.0, 0.0, 0.0, 0.0)
53
- glShadeModel(GL_FLAT)
54
+ glClearColor(0.0, 0.0, 0.0, 0.0)
55
+ glShadeModel(GL_FLAT)
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
- glPushMatrix()
61
- glutWireSphere(1.0, 20, 16) # draw sun
62
- glRotate($year, 0.0, 1.0, 0.0)
63
- glTranslate(2.0, 0.0, 0.0)
64
- glRotate($day, 0.0, 1.0, 0.0)
65
- glutWireSphere(0.2, 10, 8) # draw smaller planet
66
- glPopMatrix()
67
- glutSwapBuffers()
59
+ glClear(GL_COLOR_BUFFER_BIT)
60
+ glColor(1.0, 1.0, 1.0)
61
+
62
+ glPushMatrix()
63
+ glutWireSphere(1.0, 20, 16) # draw sun
64
+ glRotate($year, 0.0, 1.0, 0.0)
65
+ glTranslate(2.0, 0.0, 0.0)
66
+ glRotate($day, 0.0, 1.0, 0.0)
67
+ glutWireSphere(0.2, 10, 8) # draw smaller planet
68
+ glPopMatrix()
69
+ glutSwapBuffers()
68
70
  end
69
71
 
70
72
  reshape = Proc.new do |w, h|
71
- glViewport(0, 0, w, h)
72
- glMatrixMode(GL_PROJECTION)
73
- glLoadIdentity()
74
- gluPerspective(60.0, w.to_f/h.to_f, 1.0, 20.0)
75
- glMatrixMode(GL_MODELVIEW)
76
- glLoadIdentity()
77
- gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
73
+ glViewport(0, 0, w, h)
74
+ glMatrixMode(GL_PROJECTION)
75
+ glLoadIdentity()
76
+ gluPerspective(60.0, w.to_f/h.to_f, 1.0, 20.0)
77
+ glMatrixMode(GL_MODELVIEW)
78
+ glLoadIdentity()
79
+ gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
78
80
  end
79
81
 
80
82
  keyboard = Proc.new do |key, x, y|
81
- case (key)
82
- when ?d
83
- $day = ($day + 10) % 360
84
- glutPostRedisplay()
85
- when ?D
86
- $day = ($day - 10) % 360
87
- glutPostRedisplay()
88
- when ?y
89
- $year = ($year + 5) % 360
90
- glutPostRedisplay()
91
- when ?Y
92
- $year = ($year - 5) % 360
93
- glutPostRedisplay()
94
- when ?\e
95
- exit(0)
96
- end
83
+ case (key)
84
+ when ?d
85
+ $day = ($day + 10) % 360
86
+ glutPostRedisplay()
87
+ when ?D
88
+ $day = ($day - 10) % 360
89
+ glutPostRedisplay()
90
+ when ?y
91
+ $year = ($year + 5) % 360
92
+ glutPostRedisplay()
93
+ when ?Y
94
+ $year = ($year - 5) % 360
95
+ glutPostRedisplay()
96
+ when ?\e
97
+ exit(0)
98
+ end
97
99
  end
98
100
 
99
101
  glutInit
100
102
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
101
- glutInitWindowSize(500, 500)
103
+ glutInitWindowSize(500, 500)
102
104
  glutInitWindowPosition(100, 100)
103
105
  glutCreateWindow($0)
104
106
  init()
105
- glutDisplayFunc(display)
107
+ glutDisplayFunc(display)
106
108
  glutReshapeFunc(reshape)
107
109
  glutKeyboardFunc(keyboard)
108
110
  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
@@ -41,118 +41,120 @@
41
41
  # Note that the cylinder has no top or bottom and the circle
42
42
  # has a hole in it.
43
43
  require 'opengl'
44
+ require 'glu'
45
+ require 'glut'
44
46
  require 'mathn'
45
47
  include Gl,Glu,Glut
46
48
 
47
49
  $startList = nil
48
50
 
49
51
  def init
50
- mat_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
51
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
52
- mat_shininess = [ 50.0 ]
53
- light_position = [ 1.0, 1.0, 1.0, 0.0 ]
54
- model_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
55
-
56
- glClearColor(0.0, 0.0, 0.0, 0.0)
57
-
58
- glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
59
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
60
- glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
61
- glLight(GL_LIGHT0, GL_POSITION, light_position)
62
- glLightModel(GL_LIGHT_MODEL_AMBIENT, model_ambient)
63
-
64
- glEnable(GL_LIGHTING)
65
- glEnable(GL_LIGHT0)
66
- glEnable(GL_DEPTH_TEST)
67
-
68
- # Create 4 display lists, each with a different quadric object.
69
- # Different drawing styles and surface normal specifications
70
- # are demonstrated.
71
- $startList = glGenLists(4)
72
- qobj = gluNewQuadric()
73
-
74
- gluQuadricDrawStyle(qobj, GLU_FILL) # smooth shaded
75
- gluQuadricNormals(qobj, GLU_SMOOTH)
76
- glNewList($startList, GL_COMPILE)
77
- gluSphere(qobj, 0.75, 15, 10)
78
- glEndList()
79
-
80
- gluQuadricDrawStyle(qobj, GLU_FILL) # flat shaded
81
- gluQuadricNormals(qobj, GLU_FLAT)
82
- glNewList($startList+1, GL_COMPILE)
83
- gluCylinder(qobj, 0.5, 0.3, 1.0, 15, 5)
84
- glEndList()
85
-
86
- gluQuadricDrawStyle(qobj, GLU_LINE) # all polygons wireframe
87
- gluQuadricNormals(qobj, GLU_NONE)
88
- glNewList($startList+2, GL_COMPILE)
89
- gluDisk(qobj, 0.25, 1.0, 20, 4)
90
- glEndList()
91
-
92
- gluQuadricDrawStyle(qobj, GLU_SILHOUETTE) # boundary only
93
- gluQuadricNormals(qobj, GLU_NONE)
94
- glNewList($startList+3, GL_COMPILE)
95
- gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0)
96
- glEndList()
52
+ mat_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
53
+ mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
54
+ mat_shininess = [ 50.0 ]
55
+ light_position = [ 1.0, 1.0, 1.0, 0.0 ]
56
+ model_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
57
+
58
+ glClearColor(0.0, 0.0, 0.0, 0.0)
59
+
60
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
61
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
62
+ glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
63
+ glLight(GL_LIGHT0, GL_POSITION, light_position)
64
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, model_ambient)
65
+
66
+ glEnable(GL_LIGHTING)
67
+ glEnable(GL_LIGHT0)
68
+ glEnable(GL_DEPTH_TEST)
69
+
70
+ # Create 4 display lists, each with a different quadric object.
71
+ # Different drawing styles and surface normal specifications
72
+ # are demonstrated.
73
+ $startList = glGenLists(4)
74
+ qobj = gluNewQuadric()
75
+
76
+ gluQuadricDrawStyle(qobj, GLU_FILL) # smooth shaded
77
+ gluQuadricNormals(qobj, GLU_SMOOTH)
78
+ glNewList($startList, GL_COMPILE)
79
+ gluSphere(qobj, 0.75, 15, 10)
80
+ glEndList()
81
+
82
+ gluQuadricDrawStyle(qobj, GLU_FILL) # flat shaded
83
+ gluQuadricNormals(qobj, GLU_FLAT)
84
+ glNewList($startList+1, GL_COMPILE)
85
+ gluCylinder(qobj, 0.5, 0.3, 1.0, 15, 5)
86
+ glEndList()
87
+
88
+ gluQuadricDrawStyle(qobj, GLU_LINE) # all polygons wireframe
89
+ gluQuadricNormals(qobj, GLU_NONE)
90
+ glNewList($startList+2, GL_COMPILE)
91
+ gluDisk(qobj, 0.25, 1.0, 20, 4)
92
+ glEndList()
93
+
94
+ gluQuadricDrawStyle(qobj, GLU_SILHOUETTE) # boundary only
95
+ gluQuadricNormals(qobj, GLU_NONE)
96
+ glNewList($startList+3, GL_COMPILE)
97
+ gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0)
98
+ glEndList()
97
99
  end
98
100
 
99
101
  display = Proc.new do
100
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
101
- glPushMatrix()
102
-
103
- glEnable(GL_LIGHTING)
104
- glShadeModel(GL_SMOOTH)
105
- glTranslate(-1.0, -1.0, 0.0)
106
- glCallList($startList)
107
-
108
- glShadeModel(GL_FLAT)
109
- glTranslate(0.0, 2.0, 0.0)
110
- glPushMatrix()
111
- glRotate(300.0, 1.0, 0.0, 0.0)
112
- glCallList($startList+1)
113
- glPopMatrix()
114
-
115
- glDisable(GL_LIGHTING)
116
- glColor(0.0, 1.0, 1.0)
117
- glTranslate(2.0, -2.0, 0.0)
118
- glCallList($startList+2)
119
-
120
- glColor(1.0, 1.0, 0.0)
121
- glTranslate(0.0, 2.0, 0.0)
122
- glCallList($startList+3)
123
-
124
- glPopMatrix()
125
- glutSwapBuffers()
102
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
103
+ glPushMatrix()
104
+
105
+ glEnable(GL_LIGHTING)
106
+ glShadeModel(GL_SMOOTH)
107
+ glTranslate(-1.0, -1.0, 0.0)
108
+ glCallList($startList)
109
+
110
+ glShadeModel(GL_FLAT)
111
+ glTranslate(0.0, 2.0, 0.0)
112
+ glPushMatrix()
113
+ glRotate(300.0, 1.0, 0.0, 0.0)
114
+ glCallList($startList+1)
115
+ glPopMatrix()
116
+
117
+ glDisable(GL_LIGHTING)
118
+ glColor(0.0, 1.0, 1.0)
119
+ glTranslate(2.0, -2.0, 0.0)
120
+ glCallList($startList+2)
121
+
122
+ glColor(1.0, 1.0, 0.0)
123
+ glTranslate(0.0, 2.0, 0.0)
124
+ glCallList($startList+3)
125
+
126
+ glPopMatrix()
127
+ glutSwapBuffers()
126
128
  end
127
129
 
128
130
  reshape = Proc.new do |w, h|
129
- glViewport(0, 0, w, h)
130
- glMatrixMode(GL_PROJECTION)
131
- glLoadIdentity()
132
- if (w <= h)
133
- glOrtho(-2.5, 2.5, -2.5*h/w, 2.5*h/w, -10.0, 10.0)
134
- else
135
- glOrtho(-2.5*w/h, 2.5*w/h, -2.5, 2.5, -10.0, 10.0)
136
- end
137
- glMatrixMode(GL_MODELVIEW)
138
- glLoadIdentity()
131
+ glViewport(0, 0, w, h)
132
+ glMatrixMode(GL_PROJECTION)
133
+ glLoadIdentity()
134
+ if (w <= h)
135
+ glOrtho(-2.5, 2.5, -2.5*h/w, 2.5*h/w, -10.0, 10.0)
136
+ else
137
+ glOrtho(-2.5*w/h, 2.5*w/h, -2.5, 2.5, -10.0, 10.0)
138
+ end
139
+ glMatrixMode(GL_MODELVIEW)
140
+ glLoadIdentity()
139
141
  end
140
142
 
141
143
  keyboard = Proc.new do |key, x, y|
142
- case (key)
143
- when ?\e
144
- exit(0)
145
- end
144
+ case (key)
145
+ when ?\e
146
+ exit(0)
147
+ end
146
148
  end
147
149
 
148
150
  # main
149
151
  glutInit
150
152
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
151
- glutInitWindowSize(500, 500)
153
+ glutInitWindowSize(500, 500)
152
154
  glutInitWindowPosition(100, 100)
153
155
  glutCreateWindow($0)
154
156
  init()
155
- glutDisplayFunc(display)
157
+ glutDisplayFunc(display)
156
158
  glutReshapeFunc(reshape)
157
159
  glutKeyboardFunc(keyboard)
158
160
  glutMainLoop()