opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +2 -1
- data/.travis.yml +19 -0
- data/History.rdoc +26 -0
- data/Manifest.txt +3 -23
- data/README.rdoc +43 -37
- data/Rakefile +6 -62
- data/examples/NeHe/nehe_lesson02.rb +3 -2
- data/examples/NeHe/nehe_lesson03.rb +3 -2
- data/examples/NeHe/nehe_lesson04.rb +3 -1
- data/examples/NeHe/nehe_lesson05.rb +4 -1
- data/examples/NeHe/nehe_lesson06.rb +9 -6
- data/examples/NeHe/nehe_lesson07.rb +9 -6
- data/examples/NeHe/nehe_lesson08.rb +9 -6
- data/examples/NeHe/nehe_lesson09.rb +10 -6
- data/examples/NeHe/nehe_lesson11.rb +9 -6
- data/examples/NeHe/nehe_lesson12.rb +9 -6
- data/examples/NeHe/nehe_lesson16.rb +50 -47
- data/examples/NeHe/nehe_lesson19.rb +10 -7
- data/examples/NeHe/nehe_lesson36.rb +234 -229
- data/examples/OrangeBook/brick.rb +227 -225
- data/examples/OrangeBook/particle.rb +233 -231
- data/examples/RedBook/aapoly.rb +71 -70
- data/examples/RedBook/aargb.rb +54 -52
- data/examples/RedBook/accanti.rb +96 -94
- data/examples/RedBook/accpersp.rb +106 -104
- data/examples/RedBook/alpha.rb +54 -52
- data/examples/RedBook/alpha3D.rb +90 -88
- data/examples/RedBook/bezcurve.rb +48 -46
- data/examples/RedBook/bezmesh.rb +71 -69
- data/examples/RedBook/checker.rb +57 -55
- data/examples/RedBook/clip.rb +41 -39
- data/examples/RedBook/colormat.rb +72 -70
- data/examples/RedBook/cube.rb +39 -37
- data/examples/RedBook/depthcue.rb +37 -35
- data/examples/RedBook/dof.rb +110 -109
- data/examples/RedBook/double.rb +40 -38
- data/examples/RedBook/drawf.rb +30 -28
- data/examples/RedBook/feedback.rb +79 -77
- data/examples/RedBook/fog.rb +90 -89
- data/examples/RedBook/font.rb +78 -76
- data/examples/RedBook/hello.rb +29 -27
- data/examples/RedBook/image.rb +57 -55
- data/examples/RedBook/jitter.rb +131 -131
- data/examples/RedBook/light.rb +2 -1
- data/examples/RedBook/lines.rb +70 -68
- data/examples/RedBook/list.rb +48 -46
- data/examples/RedBook/material.rb +200 -199
- data/examples/RedBook/mipmap.rb +84 -82
- data/examples/RedBook/model.rb +55 -53
- data/examples/RedBook/movelight.rb +52 -50
- data/examples/RedBook/pickdepth.rb +103 -101
- data/examples/RedBook/planet.rb +46 -44
- data/examples/RedBook/quadric.rb +97 -95
- data/examples/RedBook/robot.rb +55 -53
- data/examples/RedBook/select.rb +118 -116
- data/examples/RedBook/smooth.rb +35 -33
- data/examples/RedBook/stencil.rb +96 -94
- data/examples/RedBook/stroke.rb +75 -73
- data/examples/RedBook/surface.rb +93 -91
- data/examples/RedBook/teaambient.rb +71 -69
- data/examples/RedBook/teapots.rb +105 -103
- data/examples/RedBook/tess.rb +96 -94
- data/examples/RedBook/texbind.rb +79 -77
- data/examples/RedBook/texgen.rb +88 -86
- data/examples/RedBook/texturesurf.rb +57 -55
- data/examples/RedBook/varray.rb +85 -83
- data/examples/RedBook/wrap.rb +76 -74
- data/examples/misc/OGLBench.rb +114 -113
- data/examples/misc/anisotropic.rb +154 -152
- data/examples/misc/fbo_test.rb +37 -36
- data/examples/misc/font-glut.rb +47 -46
- data/examples/misc/glfwtest.rb +16 -16
- data/examples/misc/plane.rb +13 -13
- data/examples/misc/readpixel.rb +66 -65
- data/examples/misc/sdltest.rb +21 -19
- data/examples/misc/trislam.rb +548 -547
- data/ext/opengl/common.h +16 -38
- data/ext/opengl/conv.h +39 -41
- data/ext/opengl/extconf.rb +4 -31
- data/ext/opengl/funcdef.h +126 -124
- data/ext/opengl/gl-1.0-1.1.c +1917 -1917
- data/ext/opengl/gl-1.2.c +4 -667
- data/ext/opengl/gl-1.3.c +9 -9
- data/ext/opengl/gl-1.4.c +8 -8
- data/ext/opengl/gl-1.5.c +1 -1
- data/ext/opengl/gl-2.0.c +392 -388
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +1523 -5
- data/ext/opengl/gl-enums.h +4679 -122
- data/ext/opengl/gl-error.c +7 -7
- data/ext/opengl/gl-error.h +4 -4
- data/ext/opengl/gl-ext-arb.c +468 -464
- data/ext/opengl/gl-ext-ext.c +18 -18
- data/ext/opengl/gl-ext-nv.c +15 -15
- data/ext/opengl/gl.c +2 -0
- data/ext/opengl/gl_buffer.c +92 -92
- data/ext/opengl/opengl.c +1 -7
- data/lib/opengl.rb +23 -59
- data/lib/opengl/1.9/opengl.so +0 -0
- data/lib/opengl/2.0/opengl.so +0 -0
- data/lib/opengl/2.1/opengl.so +0 -0
- data/lib/opengl/test_case.rb +1 -2
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +18 -22
- data/test/test_gl_10_11.rb +220 -220
- data/test/test_gl_12.rb +11 -122
- data/test/test_gl_13.rb +202 -210
- data/test/test_gl_14.rb +16 -19
- data/test/test_gl_15.rb +2 -4
- data/test/test_gl_20.rb +45 -58
- data/test/test_gl_21.rb +46 -163
- data/test/test_gl_ext_arb.rb +54 -72
- data/test/test_gl_ext_ati.rb +0 -2
- data/test/test_gl_ext_ext.rb +66 -66
- data/test/test_gl_ext_gremedy.rb +8 -15
- data/test/test_gl_ext_nv.rb +109 -112
- data/test/test_opengl_buffer.rb +8 -25
- data/utils/README +0 -5
- data/utils/enumgen.rb +72 -76
- data/utils/extlistgen.rb +55 -55
- metadata +90 -67
- metadata.gz.sig +0 -0
- data/Rakefile.cross +0 -107
- data/docs/build_install.txt +0 -119
- data/docs/extensions.txt.in +0 -348
- data/docs/history.txt +0 -66
- data/docs/requirements_and_design.txt +0 -117
- data/docs/roadmap.txt +0 -28
- data/docs/scientific_use.txt +0 -35
- data/docs/supplies/page_template.html +0 -71
- data/docs/thanks.txt +0 -29
- data/docs/tutorial.txt +0 -469
- data/ext/opengl/glu-enums.c +0 -164
- data/ext/opengl/glu-enums.h +0 -463
- data/ext/opengl/glu.c +0 -1534
- data/ext/opengl/glut.c +0 -1145
- data/ext/opengl/glut_callbacks.c +0 -845
- data/lib/glu.rb +0 -1
- data/lib/glut.rb +0 -1
- data/lib/opengl/opengl.so +0 -0
- data/test/test_glu.rb +0 -309
- data/utils/mkdn2html.rb +0 -59
- data/utils/post-mkdn2html.rb +0 -91
- data/website/images/ogl.jpg +0 -0
- data/website/images/tab_bottom.gif +0 -0
- data/website/style.css +0 -198
@@ -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,43 +40,45 @@
|
|
40
40
|
# routines accFrustum() and accPerspective().
|
41
41
|
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
$j8 = [
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
[-0.334818, 0.435331],
|
49
|
+
[ 0.286438, -0.393495],
|
50
|
+
[ 0.459462, 0.141540],
|
51
|
+
[-0.414498, -0.192829],
|
52
|
+
[-0.183790, 0.082102],
|
53
|
+
[-0.079263, -0.317383],
|
54
|
+
[ 0.102254, 0.299133],
|
55
|
+
[ 0.164216, -0.054399]
|
56
|
+
]
|
55
57
|
|
56
58
|
# accFrustum()
|
57
59
|
# The first 6 arguments are identical to the glFrustum() call.
|
58
|
-
#
|
59
|
-
# pixdx and pixdy are anti-alias jitter in pixels.
|
60
|
+
#
|
61
|
+
# pixdx and pixdy are anti-alias jitter in pixels.
|
60
62
|
# Set both equal to 0.0 for no anti-alias jitter.
|
61
|
-
# eyedx and eyedy are depth-of field jitter in pixels.
|
63
|
+
# eyedx and eyedy are depth-of field jitter in pixels.
|
62
64
|
# Set both equal to 0.0 for no depth of field effects.
|
63
65
|
#
|
64
|
-
# focus is distance from eye to plane in focus.
|
66
|
+
# focus is distance from eye to plane in focus.
|
65
67
|
# focus must be greater than, but not equal to 0.0.
|
66
68
|
#
|
67
|
-
# Note that accFrustum() calls glTranslatef(). You will
|
68
|
-
# probably want to insure that your ModelView matrix has been
|
69
|
+
# Note that accFrustum() calls glTranslatef(). You will
|
70
|
+
# probably want to insure that your ModelView matrix has been
|
69
71
|
# initialized to identity before calling accFrustum().
|
70
72
|
|
71
73
|
def accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
72
74
|
viewport = glGetDoublev(GL_VIEWPORT)
|
73
|
-
|
75
|
+
|
74
76
|
xwsize = right - left
|
75
77
|
ywsize = top - bottom
|
76
|
-
|
78
|
+
|
77
79
|
dx = -(pixdx*xwsize/viewport[2] + eyedx*nnear/focus)
|
78
80
|
dy = -(pixdy*ywsize/viewport[3] + eyedy*nnear/focus)
|
79
|
-
|
81
|
+
|
80
82
|
glMatrixMode(GL_PROJECTION)
|
81
83
|
glLoadIdentity()
|
82
84
|
glFrustum(left + dx, right + dx, bottom + dy, top + dy, nnear, ffar)
|
@@ -86,107 +88,107 @@ def accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy
|
|
86
88
|
end
|
87
89
|
|
88
90
|
# accPerspective()
|
89
|
-
#
|
91
|
+
#
|
90
92
|
# The first 4 arguments are identical to the gluPerspective() call.
|
91
|
-
# pixdx and pixdy are anti-alias jitter in pixels.
|
93
|
+
# pixdx and pixdy are anti-alias jitter in pixels.
|
92
94
|
# Set both equal to 0.0 for no anti-alias jitter.
|
93
|
-
# eyedx and eyedy are depth-of field jitter in pixels.
|
95
|
+
# eyedx and eyedy are depth-of field jitter in pixels.
|
94
96
|
# Set both equal to 0.0 for no depth of field effects.
|
95
97
|
#
|
96
|
-
# focus is distance from eye to plane in focus.
|
98
|
+
# focus is distance from eye to plane in focus.
|
97
99
|
# focus must be greater than, but not equal to 0.0.
|
98
100
|
#
|
99
101
|
# Note that accPerspective() calls accFrustum().
|
100
102
|
|
101
103
|
def accPerspective(fovy, aspect, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
fov2 = ((fovy*Math::PI) / 180.0) / 2.0
|
105
|
+
|
106
|
+
top = nnear / (Math::cos(fov2) / Math::sin(fov2))
|
107
|
+
bottom = -top
|
108
|
+
|
109
|
+
right = top * aspect
|
110
|
+
left = -right
|
111
|
+
|
112
|
+
accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
111
113
|
end
|
112
114
|
|
113
115
|
# Initialize lighting and other values.
|
114
116
|
def init
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
117
|
+
mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ]
|
118
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
119
|
+
light_position = [ 0.0, 0.0, 10.0, 1.0 ]
|
120
|
+
lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
|
121
|
+
|
122
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
|
123
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
124
|
+
glMaterial(GL_FRONT, GL_SHININESS, 50.0)
|
125
|
+
glLight(GL_LIGHT0, GL_POSITION, light_position)
|
126
|
+
glLightModel(GL_LIGHT_MODEL_AMBIENT, lm_ambient)
|
127
|
+
|
128
|
+
glEnable(GL_LIGHTING)
|
129
|
+
glEnable(GL_LIGHT0)
|
130
|
+
glEnable(GL_DEPTH_TEST)
|
131
|
+
glShadeModel(GL_FLAT)
|
132
|
+
|
133
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
134
|
+
glClearAccum(0.0, 0.0, 0.0, 0.0)
|
133
135
|
end
|
134
136
|
|
135
137
|
def displayObjects
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
138
|
+
torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
|
139
|
+
cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ]
|
140
|
+
sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ]
|
141
|
+
octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ]
|
142
|
+
|
143
|
+
glPushMatrix()
|
144
|
+
glTranslate(0.0, 0.0, -5.0)
|
145
|
+
glRotate(30.0, 1.0, 0.0, 0.0)
|
146
|
+
|
147
|
+
glPushMatrix()
|
148
|
+
glTranslate(-0.80, 0.35, 0.0)
|
149
|
+
glRotate(100.0, 1.0, 0.0, 0.0)
|
150
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, torus_diffuse)
|
151
|
+
glutSolidTorus(0.275, 0.85, 16, 16)
|
152
|
+
glPopMatrix()
|
153
|
+
|
154
|
+
glPushMatrix()
|
155
|
+
glTranslate(-0.75, -0.50, 0.0)
|
156
|
+
glRotate(45.0, 0.0, 0.0, 1.0)
|
157
|
+
glRotate(45.0, 1.0, 0.0, 0.0)
|
158
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, cube_diffuse)
|
159
|
+
glutSolidCube(1.5)
|
160
|
+
glPopMatrix()
|
161
|
+
|
162
|
+
glPushMatrix()
|
163
|
+
glTranslate(0.75, 0.60, 0.0)
|
164
|
+
glRotate(30.0, 1.0, 0.0, 0.0)
|
165
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, sphere_diffuse)
|
166
|
+
glutSolidSphere(1.0, 16, 16)
|
167
|
+
glPopMatrix()
|
168
|
+
|
169
|
+
glPushMatrix()
|
170
|
+
glTranslate(0.70, -0.90, 0.25)
|
171
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, octa_diffuse)
|
172
|
+
glutSolidOctahedron()
|
173
|
+
glPopMatrix()
|
174
|
+
|
175
|
+
glPopMatrix()
|
174
176
|
end
|
175
177
|
|
176
178
|
ACSIZE=8
|
177
179
|
|
178
180
|
display = proc do
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
181
|
+
viewport = glGetDoublev(GL_VIEWPORT)
|
182
|
+
|
183
|
+
glClear(GL_ACCUM_BUFFER_BIT)
|
184
|
+
for jitter in 0...ACSIZE
|
185
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
186
|
+
accPerspective(50.0, viewport[2]/ viewport[3], 1.0, 15.0, $j8[jitter][0], $j8[jitter][1], 0.0, 0.0, 1.0)
|
187
|
+
displayObjects()
|
188
|
+
glAccum(GL_ACCUM, 1.0/ACSIZE)
|
189
|
+
end
|
190
|
+
glAccum(GL_RETURN, 1.0)
|
191
|
+
glutSwapBuffers()
|
190
192
|
end
|
191
193
|
|
192
194
|
reshape = proc do |w, h|
|
data/examples/RedBook/alpha.rb
CHANGED
@@ -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
|
@@ -39,6 +39,8 @@
|
|
39
39
|
# to demonstrate the effect order has on alpha blending results.
|
40
40
|
# Use the 't' key to toggle the order of drawing polygons.
|
41
41
|
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
42
44
|
require 'mathn'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
@@ -46,70 +48,70 @@ $leftFirst = GL_TRUE
|
|
46
48
|
|
47
49
|
# Initialize alpha blending function.
|
48
50
|
def init
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
glEnable(GL_BLEND)
|
52
|
+
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
53
|
+
glShadeModel(GL_FLAT)
|
54
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
53
55
|
end
|
54
56
|
|
55
57
|
def drawLeftTriangle
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
# draw yellow triangle on LHS of screen
|
59
|
+
|
60
|
+
glBegin(GL_TRIANGLES)
|
61
|
+
glColor(1.0, 1.0, 0.0, 0.75)
|
62
|
+
glVertex(0.1, 0.9, 0.0)
|
63
|
+
glVertex(0.1, 0.1, 0.0)
|
64
|
+
glVertex(0.7, 0.5, 0.0)
|
65
|
+
glEnd()
|
64
66
|
end
|
65
67
|
|
66
68
|
def drawRightTriangle
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
# draw cyan triangle on RHS of screen
|
70
|
+
|
71
|
+
glBegin(GL_TRIANGLES)
|
72
|
+
glColor(0.0, 1.0, 1.0, 0.75)
|
73
|
+
glVertex(0.9, 0.9, 0.0)
|
74
|
+
glVertex(0.3, 0.5, 0.0)
|
75
|
+
glVertex(0.9, 0.1, 0.0)
|
76
|
+
glEnd()
|
75
77
|
end
|
76
78
|
|
77
79
|
display = Proc.new do
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
80
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
81
|
+
|
82
|
+
if ($leftFirst)
|
83
|
+
drawLeftTriangle()
|
84
|
+
drawRightTriangle()
|
85
|
+
else
|
86
|
+
drawRightTriangle()
|
87
|
+
drawLeftTriangle()
|
88
|
+
end
|
89
|
+
glutSwapBuffers()
|
88
90
|
end
|
89
91
|
|
90
92
|
reshape = Proc.new do |w, h|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
93
|
+
glViewport(0, 0, w, h)
|
94
|
+
glMatrixMode(GL_PROJECTION)
|
95
|
+
glLoadIdentity()
|
96
|
+
if (w <= h)
|
97
|
+
gluOrtho2D(0.0, 1.0, 0.0, 1.0*h/w)
|
98
|
+
else
|
99
|
+
gluOrtho2D(0.0, 1.0*w/h, 0.0, 1.0)
|
100
|
+
end
|
99
101
|
end
|
100
102
|
|
101
103
|
keyboard = Proc.new do|key, x, y|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
case (key)
|
105
|
+
when ?t,?T
|
106
|
+
$leftFirst = !$leftFirst
|
107
|
+
glutPostRedisplay()
|
108
|
+
when ?\e # Escape key
|
109
|
+
exit(0)
|
110
|
+
end
|
109
111
|
end
|
110
112
|
|
111
113
|
# Main Loop
|
112
|
-
# Open window with initial window size, title bar,
|
114
|
+
# Open window with initial window size, title bar,
|
113
115
|
# RGBA display mode, and handle input events.
|
114
116
|
glutInit
|
115
117
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
data/examples/RedBook/alpha3D.rb
CHANGED
@@ -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
|
@@ -36,11 +36,13 @@
|
|
36
36
|
#
|
37
37
|
# alpha3D.c
|
38
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
|
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
42
|
# the 'r' key to reset the scene.
|
43
43
|
require 'opengl'
|
44
|
+
require 'glu'
|
45
|
+
require 'glut'
|
44
46
|
include Gl,Glu,Glut
|
45
47
|
|
46
48
|
MAXZ=1.0
|
@@ -53,97 +55,97 @@ $sphereList=nil
|
|
53
55
|
$cubeList=nil
|
54
56
|
|
55
57
|
def init
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
58
|
+
mat_specular = [ 1.0, 1.0, 1.0, 0.15 ]
|
59
|
+
mat_shininess = [ 100.0 ]
|
60
|
+
position = [ 0.5, 0.5, 1.0, 0.0 ]
|
61
|
+
|
62
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
63
|
+
glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
|
64
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
65
|
+
|
66
|
+
glEnable(GL_LIGHTING)
|
67
|
+
glEnable(GL_LIGHT0)
|
68
|
+
glEnable(GL_DEPTH_TEST)
|
69
|
+
|
70
|
+
$sphereList = glGenLists(1)
|
71
|
+
glNewList($sphereList, GL_COMPILE)
|
72
|
+
glutSolidSphere(0.4, 16, 16)
|
73
|
+
glEndList()
|
74
|
+
|
75
|
+
$cubeList = glGenLists(1)
|
76
|
+
glNewList($cubeList, GL_COMPILE)
|
77
|
+
glutSolidCube(0.6)
|
78
|
+
glEndList()
|
77
79
|
end
|
78
80
|
|
79
81
|
display = proc do
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
82
|
+
mat_solid = [ 0.75, 0.75, 0.0, 1.0 ]
|
83
|
+
mat_zero = [ 0.0, 0.0, 0.0, 1.0 ]
|
84
|
+
mat_transparent = [ 0.0, 0.8, 0.8, 0.6 ]
|
85
|
+
mat_emission = [ 0.0, 0.3, 0.3, 0.6 ]
|
86
|
+
|
87
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
88
|
+
|
89
|
+
glPushMatrix()
|
90
|
+
glTranslate(-0.15, -0.15, $solidZ)
|
91
|
+
glMaterial(GL_FRONT, GL_EMISSION, mat_zero)
|
92
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_solid)
|
93
|
+
glCallList($sphereList)
|
94
|
+
glPopMatrix()
|
95
|
+
|
96
|
+
glPushMatrix()
|
97
|
+
glTranslate(0.15, 0.15, $transparentZ)
|
98
|
+
glRotate(15.0, 1.0, 1.0, 0.0)
|
99
|
+
glRotate(30.0, 0.0, 1.0, 0.0)
|
100
|
+
glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
|
101
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_transparent)
|
102
|
+
glEnable(GL_BLEND)
|
103
|
+
glDepthMask(GL_FALSE)
|
104
|
+
glBlendFunc(GL_SRC_ALPHA, GL_ONE)
|
105
|
+
glCallList($cubeList)
|
106
|
+
glDepthMask(GL_TRUE)
|
107
|
+
glDisable(GL_BLEND)
|
108
|
+
glPopMatrix()
|
109
|
+
|
110
|
+
glutSwapBuffers()
|
109
111
|
end
|
110
112
|
|
111
113
|
reshape = proc do |w, h|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
114
|
+
glViewport(0, 0, w, h)
|
115
|
+
glMatrixMode(GL_PROJECTION)
|
116
|
+
glLoadIdentity()
|
117
|
+
if (w <= h)
|
118
|
+
glOrtho(-1.5, 1.5, -1.5*h.to_f/w, 1.5*h.to_f/w, -10.0, 10.0)
|
119
|
+
else
|
120
|
+
glOrtho(-1.5*w.to_f/h, 1.5*w.to_f/h, -1.5, 1.5, -10.0, 10.0)
|
121
|
+
end
|
122
|
+
glMatrixMode(GL_MODELVIEW)
|
123
|
+
glLoadIdentity()
|
122
124
|
end
|
123
125
|
|
124
126
|
animate = proc do
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
if ($solidZ <= MINZ || $transparentZ >= MAXZ)
|
128
|
+
glutIdleFunc(nil)
|
129
|
+
else
|
130
|
+
$solidZ -= ZINC
|
131
|
+
$transparentZ += ZINC
|
132
|
+
glutPostRedisplay()
|
133
|
+
end
|
132
134
|
end
|
133
135
|
|
134
136
|
keyboard = proc do |key, x, y|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
137
|
+
case (key)
|
138
|
+
when ?a,?A
|
139
|
+
$solidZ = MAXZ
|
140
|
+
$transparentZ = MINZ
|
141
|
+
glutIdleFunc(animate)
|
142
|
+
when ?r, ?R
|
143
|
+
$solidZ = MAXZ
|
144
|
+
$transparentZ = MINZ
|
145
|
+
glutPostRedisplay()
|
146
|
+
when ?\e
|
147
|
+
exit(0)
|
148
|
+
end
|
147
149
|
end
|
148
150
|
|
149
151
|
glutInit()
|