ruby-opengl 0.60.1 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. metadata +36 -186
  2. data/Rakefile +0 -168
  3. data/doc/build_install.txt +0 -122
  4. data/doc/extensions.txt +0 -556
  5. data/doc/extensions.txt.in +0 -348
  6. data/doc/history.txt +0 -66
  7. data/doc/requirements_and_design.txt +0 -117
  8. data/doc/roadmap.txt +0 -28
  9. data/doc/scientific_use.txt +0 -35
  10. data/doc/supplies/page_template.html +0 -71
  11. data/doc/thanks.txt +0 -29
  12. data/doc/tutorial.txt +0 -469
  13. data/examples/NeHe/nehe_lesson02.rb +0 -117
  14. data/examples/NeHe/nehe_lesson03.rb +0 -122
  15. data/examples/NeHe/nehe_lesson04.rb +0 -133
  16. data/examples/NeHe/nehe_lesson05.rb +0 -186
  17. data/examples/NeHe/nehe_lesson36.rb +0 -303
  18. data/examples/OrangeBook/3Dlabs-License.txt +0 -33
  19. data/examples/OrangeBook/brick.frag +0 -36
  20. data/examples/OrangeBook/brick.rb +0 -376
  21. data/examples/OrangeBook/brick.vert +0 -41
  22. data/examples/OrangeBook/particle.frag +0 -17
  23. data/examples/OrangeBook/particle.rb +0 -406
  24. data/examples/OrangeBook/particle.vert +0 -38
  25. data/examples/README +0 -16
  26. data/examples/RedBook/aapoly.rb +0 -142
  27. data/examples/RedBook/aargb.rb +0 -119
  28. data/examples/RedBook/accanti.rb +0 -162
  29. data/examples/RedBook/accpersp.rb +0 -215
  30. data/examples/RedBook/alpha.rb +0 -123
  31. data/examples/RedBook/alpha3D.rb +0 -158
  32. data/examples/RedBook/bezcurve.rb +0 -105
  33. data/examples/RedBook/bezmesh.rb +0 -137
  34. data/examples/RedBook/checker.rb +0 -124
  35. data/examples/RedBook/clip.rb +0 -95
  36. data/examples/RedBook/colormat.rb +0 -135
  37. data/examples/RedBook/cube.rb +0 -69
  38. data/examples/RedBook/depthcue.rb +0 -99
  39. data/examples/RedBook/dof.rb +0 -205
  40. data/examples/RedBook/double.rb +0 -105
  41. data/examples/RedBook/drawf.rb +0 -91
  42. data/examples/RedBook/feedback.rb +0 -145
  43. data/examples/RedBook/fog.rb +0 -167
  44. data/examples/RedBook/font.rb +0 -151
  45. data/examples/RedBook/hello.rb +0 -79
  46. data/examples/RedBook/image.rb +0 -137
  47. data/examples/RedBook/jitter.rb +0 -207
  48. data/examples/RedBook/lines.rb +0 -128
  49. data/examples/RedBook/list.rb +0 -111
  50. data/examples/RedBook/material.rb +0 -275
  51. data/examples/RedBook/mipmap.rb +0 -156
  52. data/examples/RedBook/model.rb +0 -113
  53. data/examples/RedBook/movelight.rb +0 -132
  54. data/examples/RedBook/pickdepth.rb +0 -179
  55. data/examples/RedBook/planet.rb +0 -108
  56. data/examples/RedBook/quadric.rb +0 -158
  57. data/examples/RedBook/robot.rb +0 -115
  58. data/examples/RedBook/select.rb +0 -196
  59. data/examples/RedBook/smooth.rb +0 -95
  60. data/examples/RedBook/stencil.rb +0 -163
  61. data/examples/RedBook/stroke.rb +0 -167
  62. data/examples/RedBook/surface.rb +0 -166
  63. data/examples/RedBook/teaambient.rb +0 -132
  64. data/examples/RedBook/teapots.rb +0 -182
  65. data/examples/RedBook/tess.rb +0 -183
  66. data/examples/RedBook/texbind.rb +0 -147
  67. data/examples/RedBook/texgen.rb +0 -169
  68. data/examples/RedBook/texturesurf.rb +0 -128
  69. data/examples/RedBook/varray.rb +0 -159
  70. data/examples/RedBook/wrap.rb +0 -148
  71. data/examples/misc/OGLBench.rb +0 -337
  72. data/examples/misc/anisotropic.rb +0 -194
  73. data/examples/misc/fbo_test.rb +0 -356
  74. data/examples/misc/font-glut.rb +0 -46
  75. data/examples/misc/glfwtest.rb +0 -30
  76. data/examples/misc/plane.rb +0 -161
  77. data/examples/misc/readpixel.rb +0 -65
  78. data/examples/misc/sdltest.rb +0 -34
  79. data/examples/misc/trislam.rb +0 -828
  80. data/ext/common/common.h +0 -423
  81. data/ext/common/conv.h +0 -244
  82. data/ext/common/funcdef.h +0 -280
  83. data/ext/common/gl-enums.h +0 -10031
  84. data/ext/common/gl-error.h +0 -23
  85. data/ext/common/gl-types.h +0 -61
  86. data/ext/common/glu-enums.h +0 -463
  87. data/ext/gl/gl-1.0-1.1.c +0 -2817
  88. data/ext/gl/gl-1.2.c +0 -814
  89. data/ext/gl/gl-1.3.c +0 -444
  90. data/ext/gl/gl-1.4.c +0 -349
  91. data/ext/gl/gl-1.5.c +0 -225
  92. data/ext/gl/gl-2.0.c +0 -657
  93. data/ext/gl/gl-2.1.c +0 -57
  94. data/ext/gl/gl-enums.c +0 -3354
  95. data/ext/gl/gl-error.c +0 -104
  96. data/ext/gl/gl-ext-3dfx.c +0 -27
  97. data/ext/gl/gl-ext-arb.c +0 -866
  98. data/ext/gl/gl-ext-ati.c +0 -41
  99. data/ext/gl/gl-ext-ext.c +0 -890
  100. data/ext/gl/gl-ext-gremedy.c +0 -41
  101. data/ext/gl/gl-ext-nv.c +0 -679
  102. data/ext/gl/gl.c +0 -214
  103. data/ext/gl/mkrf_conf.rb +0 -34
  104. data/ext/glu/glu-enums.c +0 -164
  105. data/ext/glu/glu.c +0 -1530
  106. data/ext/glu/mkrf_conf.rb +0 -35
  107. data/ext/glut/glut.c +0 -1623
  108. data/ext/glut/mkrf_conf.rb +0 -37
  109. data/lib/opengl.rb +0 -84
  110. data/test/README +0 -10
  111. data/test/tc_common.rb +0 -98
  112. data/test/tc_ext_arb.rb +0 -467
  113. data/test/tc_ext_ati.rb +0 -33
  114. data/test/tc_ext_ext.rb +0 -551
  115. data/test/tc_ext_gremedy.rb +0 -36
  116. data/test/tc_ext_nv.rb +0 -357
  117. data/test/tc_func_10_11.rb +0 -1281
  118. data/test/tc_func_12.rb +0 -186
  119. data/test/tc_func_13.rb +0 -229
  120. data/test/tc_func_14.rb +0 -197
  121. data/test/tc_func_15.rb +0 -270
  122. data/test/tc_func_20.rb +0 -346
  123. data/test/tc_func_21.rb +0 -541
  124. data/test/tc_glu.rb +0 -310
  125. data/test/tc_include_gl.rb +0 -35
  126. data/test/tc_misc.rb +0 -54
  127. data/test/tc_require_gl.rb +0 -34
@@ -1,215 +0,0 @@
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
- # accpersp.c
38
- # Use the accumulation buffer to do full-scene antialiasing
39
- # on a scene with perspective projection, using the special
40
- # routines accFrustum() and accPerspective().
41
-
42
- require 'opengl'
43
- include Gl,Glu,Glut
44
-
45
- $j8 = [
46
- [-0.334818, 0.435331],
47
- [ 0.286438, -0.393495],
48
- [ 0.459462, 0.141540],
49
- [-0.414498, -0.192829],
50
- [-0.183790, 0.082102],
51
- [-0.079263, -0.317383],
52
- [ 0.102254, 0.299133],
53
- [ 0.164216, -0.054399]
54
- ]
55
-
56
- # accFrustum()
57
- # The first 6 arguments are identical to the glFrustum() call.
58
- #
59
- # pixdx and pixdy are anti-alias jitter in pixels.
60
- # Set both equal to 0.0 for no anti-alias jitter.
61
- # eyedx and eyedy are depth-of field jitter in pixels.
62
- # Set both equal to 0.0 for no depth of field effects.
63
- #
64
- # focus is distance from eye to plane in focus.
65
- # focus must be greater than, but not equal to 0.0.
66
- #
67
- # Note that accFrustum() calls glTranslatef(). You will
68
- # probably want to insure that your ModelView matrix has been
69
- # initialized to identity before calling accFrustum().
70
-
71
- def accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
72
- viewport = glGetDoublev(GL_VIEWPORT)
73
-
74
- xwsize = right - left
75
- ywsize = top - bottom
76
-
77
- dx = -(pixdx*xwsize/viewport[2] + eyedx*nnear/focus)
78
- dy = -(pixdy*ywsize/viewport[3] + eyedy*nnear/focus)
79
-
80
- glMatrixMode(GL_PROJECTION)
81
- glLoadIdentity()
82
- glFrustum(left + dx, right + dx, bottom + dy, top + dy, nnear, ffar)
83
- glMatrixMode(GL_MODELVIEW)
84
- glLoadIdentity()
85
- glTranslate(-eyedx, -eyedy, 0.0)
86
- end
87
-
88
- # accPerspective()
89
- #
90
- # The first 4 arguments are identical to the gluPerspective() call.
91
- # pixdx and pixdy are anti-alias jitter in pixels.
92
- # Set both equal to 0.0 for no anti-alias jitter.
93
- # eyedx and eyedy are depth-of field jitter in pixels.
94
- # Set both equal to 0.0 for no depth of field effects.
95
- #
96
- # focus is distance from eye to plane in focus.
97
- # focus must be greater than, but not equal to 0.0.
98
- #
99
- # Note that accPerspective() calls accFrustum().
100
-
101
- def accPerspective(fovy, aspect, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
102
- fov2 = ((fovy*Math::PI) / 180.0) / 2.0
103
-
104
- top = nnear / (Math::cos(fov2) / Math::sin(fov2))
105
- bottom = -top
106
-
107
- right = top * aspect
108
- left = -right
109
-
110
- accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
111
- end
112
-
113
- # Initialize lighting and other values.
114
- def init
115
- mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ]
116
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
117
- light_position = [ 0.0, 0.0, 10.0, 1.0 ]
118
- lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
119
-
120
- glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
121
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
122
- glMaterial(GL_FRONT, GL_SHININESS, 50.0)
123
- glLight(GL_LIGHT0, GL_POSITION, light_position)
124
- glLightModel(GL_LIGHT_MODEL_AMBIENT, lm_ambient)
125
-
126
- glEnable(GL_LIGHTING)
127
- glEnable(GL_LIGHT0)
128
- glEnable(GL_DEPTH_TEST)
129
- glShadeModel(GL_FLAT)
130
-
131
- glClearColor(0.0, 0.0, 0.0, 0.0)
132
- glClearAccum(0.0, 0.0, 0.0, 0.0)
133
- end
134
-
135
- def displayObjects
136
- torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
137
- cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ]
138
- sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ]
139
- octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ]
140
-
141
- glPushMatrix()
142
- glTranslate(0.0, 0.0, -5.0)
143
- glRotate(30.0, 1.0, 0.0, 0.0)
144
-
145
- glPushMatrix()
146
- glTranslate(-0.80, 0.35, 0.0)
147
- glRotate(100.0, 1.0, 0.0, 0.0)
148
- glMaterial(GL_FRONT, GL_DIFFUSE, torus_diffuse)
149
- glutSolidTorus(0.275, 0.85, 16, 16)
150
- glPopMatrix()
151
-
152
- glPushMatrix()
153
- glTranslate(-0.75, -0.50, 0.0)
154
- glRotate(45.0, 0.0, 0.0, 1.0)
155
- glRotate(45.0, 1.0, 0.0, 0.0)
156
- glMaterial(GL_FRONT, GL_DIFFUSE, cube_diffuse)
157
- glutSolidCube(1.5)
158
- glPopMatrix()
159
-
160
- glPushMatrix()
161
- glTranslate(0.75, 0.60, 0.0)
162
- glRotate(30.0, 1.0, 0.0, 0.0)
163
- glMaterial(GL_FRONT, GL_DIFFUSE, sphere_diffuse)
164
- glutSolidSphere(1.0, 16, 16)
165
- glPopMatrix()
166
-
167
- glPushMatrix()
168
- glTranslate(0.70, -0.90, 0.25)
169
- glMaterial(GL_FRONT, GL_DIFFUSE, octa_diffuse)
170
- glutSolidOctahedron()
171
- glPopMatrix()
172
-
173
- glPopMatrix()
174
- end
175
-
176
- ACSIZE=8
177
-
178
- display = proc do
179
- viewport = glGetDoublev(GL_VIEWPORT)
180
-
181
- glClear(GL_ACCUM_BUFFER_BIT)
182
- for jitter in 0...ACSIZE
183
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
184
- accPerspective(50.0, viewport[2]/ viewport[3], 1.0, 15.0, $j8[jitter][0], $j8[jitter][1], 0.0, 0.0, 1.0)
185
- displayObjects()
186
- glAccum(GL_ACCUM, 1.0/ACSIZE)
187
- end
188
- glAccum(GL_RETURN, 1.0)
189
- glutSwapBuffers()
190
- end
191
-
192
- reshape = proc do |w, h|
193
- glViewport(0, 0, w, h)
194
- end
195
-
196
- keyboard = proc do |key, x, y|
197
- case (key)
198
- when ?\e
199
- exit(0)
200
- end
201
- end
202
-
203
- # Main Loop
204
- # Be certain you request an accumulation buffer.
205
-
206
- glutInit()
207
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ACCUM | GLUT_DEPTH)
208
- glutInitWindowSize(500, 500)
209
- glutInitWindowPosition(100, 100)
210
- glutCreateWindow($0)
211
- init()
212
- glutReshapeFunc(reshape)
213
- glutDisplayFunc(display)
214
- glutKeyboardFunc(keyboard)
215
- glutMainLoop()
@@ -1,123 +0,0 @@
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
- # alpha.c
38
- # This program draws several overlapping filled polygons
39
- # to demonstrate the effect order has on alpha blending results.
40
- # Use the 't' key to toggle the order of drawing polygons.
41
- require 'opengl'
42
- require 'mathn'
43
- include Gl,Glu,Glut
44
-
45
- $leftFirst = GL_TRUE
46
-
47
- # Initialize alpha blending function.
48
- def init
49
- glEnable(GL_BLEND)
50
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
51
- glShadeModel(GL_FLAT)
52
- glClearColor(0.0, 0.0, 0.0, 0.0)
53
- end
54
-
55
- def drawLeftTriangle
56
- # draw yellow triangle on LHS of screen
57
-
58
- glBegin(GL_TRIANGLES)
59
- glColor(1.0, 1.0, 0.0, 0.75)
60
- glVertex(0.1, 0.9, 0.0)
61
- glVertex(0.1, 0.1, 0.0)
62
- glVertex(0.7, 0.5, 0.0)
63
- glEnd()
64
- end
65
-
66
- def drawRightTriangle
67
- # draw cyan triangle on RHS of screen
68
-
69
- glBegin(GL_TRIANGLES)
70
- glColor(0.0, 1.0, 1.0, 0.75)
71
- glVertex(0.9, 0.9, 0.0)
72
- glVertex(0.3, 0.5, 0.0)
73
- glVertex(0.9, 0.1, 0.0)
74
- glEnd()
75
- end
76
-
77
- display = Proc.new do
78
- glClear(GL_COLOR_BUFFER_BIT)
79
-
80
- if ($leftFirst)
81
- drawLeftTriangle()
82
- drawRightTriangle()
83
- else
84
- drawRightTriangle()
85
- drawLeftTriangle()
86
- end
87
- glutSwapBuffers()
88
- end
89
-
90
- reshape = Proc.new do |w, h|
91
- glViewport(0, 0, w, h)
92
- glMatrixMode(GL_PROJECTION)
93
- glLoadIdentity()
94
- if (w <= h)
95
- gluOrtho2D(0.0, 1.0, 0.0, 1.0*h/w)
96
- else
97
- gluOrtho2D(0.0, 1.0*w/h, 0.0, 1.0)
98
- end
99
- end
100
-
101
- keyboard = Proc.new do|key, x, y|
102
- case (key)
103
- when ?t,?T
104
- $leftFirst = !$leftFirst
105
- glutPostRedisplay()
106
- when ?\e # Escape key
107
- exit(0)
108
- end
109
- end
110
-
111
- # Main Loop
112
- # Open window with initial window size, title bar,
113
- # RGBA display mode, and handle input events.
114
- glutInit
115
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
116
- glutInitWindowSize(500, 500)
117
- glutInitWindowPosition(100, 100)
118
- glutCreateWindow($0)
119
- init()
120
- glutReshapeFunc(reshape)
121
- glutKeyboardFunc(keyboard)
122
- glutDisplayFunc(display)
123
- glutMainLoop()
@@ -1,158 +0,0 @@
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
- # alpha3D.c
38
- # This program demonstrates how to intermix opaque and
39
- # alpha blended polygons in the same scene, by using
40
- # glDepthMask. Press the 'a' key to animate moving the
41
- # transparent object through the opaque object. Press
42
- # the 'r' key to reset the scene.
43
- require 'opengl'
44
- include Gl,Glu,Glut
45
-
46
- MAXZ=1.0
47
- MINZ=-2.0
48
- ZINC=0.1
49
-
50
- $solidZ = MAXZ
51
- $transparentZ = MINZ
52
- $sphereList=nil
53
- $cubeList=nil
54
-
55
- def init
56
- mat_specular = [ 1.0, 1.0, 1.0, 0.15 ]
57
- mat_shininess = [ 100.0 ]
58
- position = [ 0.5, 0.5, 1.0, 0.0 ]
59
-
60
- glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
61
- glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
62
- glLight(GL_LIGHT0, GL_POSITION, position)
63
-
64
- glEnable(GL_LIGHTING)
65
- glEnable(GL_LIGHT0)
66
- glEnable(GL_DEPTH_TEST)
67
-
68
- $sphereList = glGenLists(1)
69
- glNewList($sphereList, GL_COMPILE)
70
- glutSolidSphere(0.4, 16, 16)
71
- glEndList()
72
-
73
- $cubeList = glGenLists(1)
74
- glNewList($cubeList, GL_COMPILE)
75
- glutSolidCube(0.6)
76
- glEndList()
77
- end
78
-
79
- display = proc do
80
- mat_solid = [ 0.75, 0.75, 0.0, 1.0 ]
81
- mat_zero = [ 0.0, 0.0, 0.0, 1.0 ]
82
- mat_transparent = [ 0.0, 0.8, 0.8, 0.6 ]
83
- mat_emission = [ 0.0, 0.3, 0.3, 0.6 ]
84
-
85
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
86
-
87
- glPushMatrix()
88
- glTranslate(-0.15, -0.15, $solidZ)
89
- glMaterial(GL_FRONT, GL_EMISSION, mat_zero)
90
- glMaterial(GL_FRONT, GL_DIFFUSE, mat_solid)
91
- glCallList($sphereList)
92
- glPopMatrix()
93
-
94
- glPushMatrix()
95
- glTranslate(0.15, 0.15, $transparentZ)
96
- glRotate(15.0, 1.0, 1.0, 0.0)
97
- glRotate(30.0, 0.0, 1.0, 0.0)
98
- glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
99
- glMaterial(GL_FRONT, GL_DIFFUSE, mat_transparent)
100
- glEnable(GL_BLEND)
101
- glDepthMask(GL_FALSE)
102
- glBlendFunc(GL_SRC_ALPHA, GL_ONE)
103
- glCallList($cubeList)
104
- glDepthMask(GL_TRUE)
105
- glDisable(GL_BLEND)
106
- glPopMatrix()
107
-
108
- glutSwapBuffers()
109
- end
110
-
111
- reshape = proc do |w, h|
112
- glViewport(0, 0, w, h)
113
- glMatrixMode(GL_PROJECTION)
114
- glLoadIdentity()
115
- if (w <= h)
116
- glOrtho(-1.5, 1.5, -1.5*h.to_f/w, 1.5*h.to_f/w, -10.0, 10.0)
117
- else
118
- glOrtho(-1.5*w.to_f/h, 1.5*w.to_f/h, -1.5, 1.5, -10.0, 10.0)
119
- end
120
- glMatrixMode(GL_MODELVIEW)
121
- glLoadIdentity()
122
- end
123
-
124
- animate = proc do
125
- if ($solidZ <= MINZ || $transparentZ >= MAXZ)
126
- glutIdleFunc(nil)
127
- else
128
- $solidZ -= ZINC
129
- $transparentZ += ZINC
130
- glutPostRedisplay()
131
- end
132
- end
133
-
134
- keyboard = proc do |key, x, y|
135
- case (key)
136
- when ?a,?A
137
- $solidZ = MAXZ
138
- $transparentZ = MINZ
139
- glutIdleFunc(animate)
140
- when ?r, ?R
141
- $solidZ = MAXZ
142
- $transparentZ = MINZ
143
- glutPostRedisplay()
144
- when ?\e
145
- exit(0)
146
- end
147
- end
148
-
149
- glutInit()
150
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
151
- glutInitWindowSize(500, 500)
152
- glutInitWindowPosition(100, 100)
153
- glutCreateWindow($0)
154
- init()
155
- glutReshapeFunc(reshape)
156
- glutKeyboardFunc(keyboard)
157
- glutDisplayFunc(display)
158
- glutMainLoop()