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.
- 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
data/examples/RedBook/dof.rb
CHANGED
@@ -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
|
@@ -44,153 +44,155 @@
|
|
44
44
|
# the viewing volume is at the same position, each time. In
|
45
45
|
# this case, the gold teapot remains in focus.
|
46
46
|
require 'opengl'
|
47
|
-
require '
|
47
|
+
require 'glu'
|
48
|
+
require 'glut'
|
49
|
+
require_relative 'jitter'
|
48
50
|
include Gl,Glu,Glut
|
49
51
|
|
50
52
|
# accFrustum()
|
51
53
|
# The first 6 arguments are identical to the glFrustum() call.
|
52
|
-
#
|
53
|
-
# pixdx and pixdy are anti-alias jitter in pixels.
|
54
|
+
#
|
55
|
+
# pixdx and pixdy are anti-alias jitter in pixels.
|
54
56
|
# Set both equal to 0.0 for no anti-alias jitter.
|
55
|
-
# eyedx and eyedy are depth-of field jitter in pixels.
|
57
|
+
# eyedx and eyedy are depth-of field jitter in pixels.
|
56
58
|
# Set both equal to 0.0 for no depth of field effects.
|
57
59
|
#
|
58
|
-
# focus is distance from eye to plane in focus.
|
60
|
+
# focus is distance from eye to plane in focus.
|
59
61
|
# focus must be greater than, but not equal to 0.0.
|
60
62
|
#
|
61
|
-
# Note that accFrustum() calls glTranslatef(). You will
|
62
|
-
# probably want to insure that your ModelView matrix has been
|
63
|
+
# Note that accFrustum() calls glTranslatef(). You will
|
64
|
+
# probably want to insure that your ModelView matrix has been
|
63
65
|
# initialized to identity before calling accFrustum().
|
64
66
|
def accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
67
|
+
viewport = glGetDoublev(GL_VIEWPORT)
|
68
|
+
|
69
|
+
xwsize = right - left
|
70
|
+
ywsize = top - bottom
|
71
|
+
|
72
|
+
dx = -(pixdx*xwsize/viewport[2] + eyedx*nnear/focus)
|
73
|
+
dy = -(pixdy*ywsize/viewport[3] + eyedy*nnear/focus)
|
74
|
+
|
75
|
+
glMatrixMode(GL_PROJECTION)
|
76
|
+
glLoadIdentity()
|
77
|
+
glFrustum(left + dx, right + dx, bottom + dy, top + dy, nnear, ffar)
|
78
|
+
glMatrixMode(GL_MODELVIEW)
|
79
|
+
glLoadIdentity()
|
80
|
+
glTranslate(-eyedx, -eyedy, 0.0)
|
79
81
|
end
|
80
82
|
|
81
83
|
# accPerspective()
|
82
|
-
#
|
84
|
+
#
|
83
85
|
# The first 4 arguments are identical to the gluPerspective() call.
|
84
|
-
# pixdx and pixdy are anti-alias jitter in pixels.
|
86
|
+
# pixdx and pixdy are anti-alias jitter in pixels.
|
85
87
|
# Set both equal to 0.0 for no anti-alias jitter.
|
86
|
-
# eyedx and eyedy are depth-of field jitter in pixels.
|
88
|
+
# eyedx and eyedy are depth-of field jitter in pixels.
|
87
89
|
# Set both equal to 0.0 for no depth of field effects.
|
88
90
|
#
|
89
|
-
# focus is distance from eye to plane in focus.
|
91
|
+
# focus is distance from eye to plane in focus.
|
90
92
|
# focus must be greater than, but not equal to 0.0.
|
91
93
|
#
|
92
94
|
# Note that accPerspective() calls accFrustum().
|
93
95
|
def accPerspective(fovy, aspect, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
96
|
+
fov2 = ((fovy*Math::PI) / 180.0) / 2.0
|
97
|
+
|
98
|
+
top = nnear / (Math::cos(fov2) / Math::sin(fov2))
|
99
|
+
bottom = -top
|
100
|
+
|
101
|
+
right = top * aspect
|
102
|
+
left = -right
|
103
|
+
|
104
|
+
accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
103
105
|
end
|
104
106
|
|
105
107
|
|
106
108
|
def myinit
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
109
|
+
ambient = [ 0.0, 0.0, 0.0, 1.0 ]
|
110
|
+
diffuse = [ 1.0, 1.0, 1.0, 1.0 ]
|
111
|
+
position = [ 0.0, 3.0, 3.0, 0.0 ]
|
112
|
+
|
113
|
+
lmodel_ambient = [ 0.2, 0.2, 0.2, 1.0 ]
|
114
|
+
local_view = [ 0.0 ]
|
115
|
+
|
116
|
+
glEnable(GL_DEPTH_TEST)
|
117
|
+
glDepthFunc(GL_LESS)
|
118
|
+
|
119
|
+
glLight(GL_LIGHT0, GL_AMBIENT, ambient)
|
120
|
+
glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
|
121
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
122
|
+
|
123
|
+
glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
|
124
|
+
glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
|
125
|
+
|
126
|
+
glFrontFace(GL_CW)
|
127
|
+
glEnable(GL_LIGHTING)
|
128
|
+
glEnable(GL_LIGHT0)
|
129
|
+
glEnable(GL_AUTO_NORMAL)
|
130
|
+
glEnable(GL_NORMALIZE)
|
131
|
+
|
132
|
+
glMatrixMode(GL_MODELVIEW)
|
133
|
+
glLoadIdentity()
|
134
|
+
|
135
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
136
|
+
glClearAccum(0.0, 0.0, 0.0, 0.0)
|
135
137
|
end
|
136
138
|
|
137
139
|
def renderTeapot (x, y, z, ambr, ambg, ambb, difr, difg, difb, specr, specg, specb, shine)
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
140
|
+
glPushMatrix()
|
141
|
+
glTranslate(x, y, z)
|
142
|
+
mat = []
|
143
|
+
mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0
|
144
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat)
|
145
|
+
mat[0] = difr; mat[1] = difg; mat[2] = difb
|
146
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat)
|
147
|
+
mat[0] = specr; mat[1] = specg; mat[2] = specb
|
148
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat)
|
149
|
+
glMaterial(GL_FRONT, GL_SHININESS, shine*128.0)
|
150
|
+
glutSolidTeapot(0.5)
|
151
|
+
glPopMatrix()
|
150
152
|
end
|
151
153
|
|
152
|
-
# display() draws 5 teapots into the accumulation buffer
|
154
|
+
# display() draws 5 teapots into the accumulation buffer
|
153
155
|
# several times each time with a jittered perspective.
|
154
|
-
# The focal point is at z = 5.0, so the gold teapot will
|
156
|
+
# The focal point is at z = 5.0, so the gold teapot will
|
155
157
|
# stay in focus. The amount of jitter is adjusted by the
|
156
158
|
# magnitude of the accPerspective() jitter in this example, 0.33.
|
157
159
|
# In this example, the teapots are drawn 8 times. See jitter.rb
|
158
160
|
display = proc do
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
161
|
+
viewport = glGetDoublev(GL_VIEWPORT)
|
162
|
+
glClear(GL_ACCUM_BUFFER_BIT)
|
163
|
+
|
164
|
+
for jitter in 0...8
|
165
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
166
|
+
accPerspective(45.0,
|
167
|
+
viewport[2]/ viewport[3],
|
168
|
+
1.0, 15.0, 0.0, 0.0,
|
169
|
+
0.33*$j8[jitter][0], 0.33*$j8[jitter][1], 5.0)
|
170
|
+
# ruby, gold, silver, emerald, and cyan teapots
|
171
|
+
renderTeapot(-1.1, -0.5, -4.5, 0.1745, 0.01175, 0.01175, 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6)
|
172
|
+
renderTeapot(-0.5, -0.5, -5.0, 0.24725, 0.1995, 0.0745, 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4)
|
173
|
+
renderTeapot(0.2, -0.5, -5.5, 0.19225, 0.19225, 0.19225, 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4)
|
174
|
+
renderTeapot(1.0, -0.5, -6.0, 0.0215, 0.1745, 0.0215, 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6)
|
175
|
+
renderTeapot(1.8, -0.5, -6.5, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, 0.50196078, 0.50196078, 0.50196078, 0.25)
|
176
|
+
glAccum(GL_ACCUM, 0.125)
|
177
|
+
end
|
178
|
+
|
179
|
+
glAccum(GL_RETURN, 1.0)
|
180
|
+
glutSwapBuffers()
|
179
181
|
end
|
180
182
|
|
181
183
|
myReshape = proc do |w, h|
|
182
|
-
|
184
|
+
glViewport(0, 0, w, h)
|
183
185
|
end
|
184
186
|
|
185
187
|
keyboard = proc do |key, x, y|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
188
|
+
case (key)
|
189
|
+
when ?\e
|
190
|
+
exit(0)
|
191
|
+
end
|
190
192
|
end
|
191
193
|
|
192
194
|
# Main Loop
|
193
|
-
# Open window with initial window size, title bar,
|
195
|
+
# Open window with initial window size, title bar,
|
194
196
|
# RGBA display mode, depth buffer, and handle input events.
|
195
197
|
glutInit()
|
196
198
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_ACCUM | GLUT_DEPTH)
|
@@ -202,4 +204,3 @@ glutReshapeFunc(myReshape)
|
|
202
204
|
glutDisplayFunc(display)
|
203
205
|
glutKeyboardFunc(keyboard)
|
204
206
|
glutMainLoop()
|
205
|
-
|
data/examples/RedBook/double.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,67 +39,69 @@
|
|
39
39
|
# Pressing the left mouse button rotates the rectangle.
|
40
40
|
# Pressing the middle mouse button stops the rotation.
|
41
41
|
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
42
44
|
require 'rational'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
$spin = 0.0
|
46
48
|
|
47
49
|
display = Proc.new do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
51
|
+
glPushMatrix()
|
52
|
+
glRotate($spin, 0.0, 0.0, 1.0)
|
53
|
+
glColor(1.0, 1.0, 1.0)
|
54
|
+
glRect(-25.0, -25.0, 25.0, 25.0)
|
55
|
+
glPopMatrix()
|
56
|
+
glutSwapBuffers()
|
55
57
|
end
|
56
58
|
|
57
59
|
$spinDisplay = Proc.new do
|
58
|
-
|
59
|
-
|
60
|
-
|
60
|
+
$spin = $spin + 4.0
|
61
|
+
$spin = $spin - 360.0 if ($spin > 360.0)
|
62
|
+
glutPostRedisplay()
|
61
63
|
end
|
62
64
|
|
63
65
|
def init
|
64
|
-
|
65
|
-
|
66
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
67
|
+
glShadeModel(GL_FLAT)
|
66
68
|
end
|
67
69
|
|
68
70
|
reshape = Proc.new do |w, h|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
glViewport(0, 0, w, h)
|
72
|
+
glMatrixMode(GL_PROJECTION)
|
73
|
+
glLoadIdentity()
|
74
|
+
glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0)
|
75
|
+
glMatrixMode(GL_MODELVIEW)
|
76
|
+
glLoadIdentity()
|
75
77
|
end
|
76
78
|
|
77
79
|
mouse = Proc.new do |button, state, x, y|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
case button
|
81
|
+
when GLUT_LEFT_BUTTON
|
82
|
+
glutIdleFunc($spinDisplay) if (state == GLUT_DOWN)
|
83
|
+
when GLUT_MIDDLE_BUTTON
|
84
|
+
glutIdleFunc(nil) if (state == GLUT_DOWN)
|
85
|
+
end
|
84
86
|
end
|
85
87
|
|
86
88
|
keyboard = Proc.new do |key, x, y|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
case (key)
|
90
|
+
when ?\e
|
91
|
+
exit(0)
|
92
|
+
end
|
91
93
|
end
|
92
|
-
|
94
|
+
|
93
95
|
# Request double buffer display mode.
|
94
96
|
# Register mouse input callback functions
|
95
97
|
glutInit
|
96
98
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
97
|
-
glutInitWindowSize(500, 500)
|
99
|
+
glutInitWindowSize(500, 500)
|
98
100
|
glutInitWindowPosition(100, 100)
|
99
101
|
glutCreateWindow($0)
|
100
102
|
init()
|
101
|
-
glutDisplayFunc(display)
|
102
|
-
glutReshapeFunc(reshape)
|
103
|
+
glutDisplayFunc(display)
|
104
|
+
glutReshapeFunc(reshape)
|
103
105
|
glutKeyboardFunc(keyboard)
|
104
106
|
glutMouseFunc(mouse)
|
105
107
|
glutMainLoop()
|
data/examples/RedBook/drawf.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
|
@@ -38,46 +38,48 @@
|
|
38
38
|
# Draws the bitmapped letter F on the screen (several times).
|
39
39
|
# This demonstrates use of the glBitmap() call.
|
40
40
|
require 'opengl'
|
41
|
+
require 'glu'
|
42
|
+
require 'glut'
|
41
43
|
include Gl,Glu,Glut
|
42
44
|
|
43
45
|
$rasters = [
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00,
|
47
|
+
0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00,
|
48
|
+
0xff, 0xc0, 0xff, 0xc0
|
47
49
|
].pack("C*")
|
48
50
|
|
49
51
|
def init
|
50
|
-
|
51
|
-
|
52
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
|
53
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
52
54
|
end
|
53
55
|
|
54
56
|
display = Proc.new do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
58
|
+
glColor(1.0, 1.0, 1.0)
|
59
|
+
glRasterPos2i(20, 20)
|
60
|
+
glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, $rasters)
|
61
|
+
glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, $rasters)
|
62
|
+
glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, $rasters)
|
63
|
+
glutSwapBuffers()
|
62
64
|
end
|
63
65
|
|
64
66
|
reshape = Proc.new do |w, h|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
glViewport(0, 0, w, h)
|
68
|
+
glMatrixMode(GL_PROJECTION)
|
69
|
+
glLoadIdentity()
|
70
|
+
glOrtho(0, w, 0, h, -1.0, 1.0)
|
71
|
+
glMatrixMode(GL_MODELVIEW)
|
70
72
|
end
|
71
73
|
|
72
74
|
keyboard = Proc.new do |key, x, y|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
case (key)
|
76
|
+
when ?\e
|
77
|
+
exit(0)
|
78
|
+
end
|
77
79
|
end
|
78
80
|
|
79
81
|
# Main Loop
|
80
|
-
# Open window with initial window size, title bar,
|
82
|
+
# Open window with initial window size, title bar,
|
81
83
|
# RGBA display mode, and handle input events.
|
82
84
|
glutInit
|
83
85
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|