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
data/examples/RedBook/mipmap.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
|
@@ -43,6 +43,8 @@
|
|
43
43
|
# Thus, the quadrilateral which is drawn is drawn with several
|
44
44
|
# different colors.
|
45
45
|
require 'opengl'
|
46
|
+
require 'glu'
|
47
|
+
require 'glut'
|
46
48
|
require 'mathn'
|
47
49
|
include Gl,Glu,Glut
|
48
50
|
|
@@ -54,94 +56,94 @@ $mipmapImage2 = []
|
|
54
56
|
$mipmapImage1 = []
|
55
57
|
|
56
58
|
def makeImages
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
59
|
+
for i in 0..31
|
60
|
+
for j in 0..31
|
61
|
+
$mipmapImage32[(j*32+i)*3+0] = 255
|
62
|
+
$mipmapImage32[(j*32+i)*3+1] = 255
|
63
|
+
$mipmapImage32[(j*32+i)*3+2] = 0
|
64
|
+
end
|
65
|
+
end
|
66
|
+
for i in 0..15
|
67
|
+
for j in 0..15
|
68
|
+
$mipmapImage16[(j*16+i)*3+0] = 255
|
69
|
+
$mipmapImage16[(j*16+i)*3+1] = 0
|
70
|
+
$mipmapImage16[(j*16+i)*3+2] = 255
|
71
|
+
end
|
72
|
+
end
|
73
|
+
for i in 0..7
|
74
|
+
for j in 0..7
|
75
|
+
$mipmapImage8[(j*8+i)*3+0] = 255
|
76
|
+
$mipmapImage8[(j*8+i)*3+1] = 0
|
77
|
+
$mipmapImage8[(j*8+i)*3+2] = 0
|
78
|
+
end
|
79
|
+
end
|
80
|
+
for i in 0..3
|
81
|
+
for j in 0..3
|
82
|
+
$mipmapImage4[(j*4+i)*3+0] = 0
|
83
|
+
$mipmapImage4[(j*4+i)*3+1] = 255
|
84
|
+
$mipmapImage4[(j*4+i)*3+2] = 0
|
85
|
+
end
|
86
|
+
end
|
87
|
+
for i in 0..1
|
88
|
+
for j in 0..1
|
89
|
+
$mipmapImage2[(j*2+i)*3+0] = 0
|
90
|
+
$mipmapImage2[(j*2+i)*3+1] = 0
|
91
|
+
$mipmapImage2[(j*2+i)*3+2] = 255
|
92
|
+
end
|
93
|
+
end
|
94
|
+
$mipmapImage1[0] = 255
|
95
|
+
$mipmapImage1[1] = 255
|
96
|
+
$mipmapImage1[2] = 255
|
95
97
|
end
|
96
98
|
|
97
99
|
def myinit
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
100
|
+
glEnable(GL_DEPTH_TEST)
|
101
|
+
glDepthFunc(GL_LESS)
|
102
|
+
glShadeModel(GL_FLAT)
|
103
|
+
|
104
|
+
glTranslate(0.0, 0.0, -3.6)
|
105
|
+
makeImages()
|
106
|
+
glPixelStore(GL_UNPACK_ALIGNMENT, 1)
|
107
|
+
glTexImage2D(GL_TEXTURE_2D, 0, 3, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage32.pack("C*"))
|
108
|
+
glTexImage2D(GL_TEXTURE_2D, 1, 3, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage16.pack("C*"))
|
109
|
+
glTexImage2D(GL_TEXTURE_2D, 2, 3, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage8.pack("C*"))
|
110
|
+
glTexImage2D(GL_TEXTURE_2D, 3, 3, 4, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage4.pack("C*"))
|
111
|
+
glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage2.pack("C*"))
|
112
|
+
glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, $mipmapImage1.pack("C*"))
|
113
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
|
114
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
|
115
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
116
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
117
|
+
GL_NEAREST_MIPMAP_NEAREST)
|
118
|
+
glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
|
119
|
+
glEnable(GL_TEXTURE_2D)
|
118
120
|
end
|
119
121
|
|
120
122
|
display = Proc.new do
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
123
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
124
|
+
glBegin(GL_QUADS)
|
125
|
+
glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
|
126
|
+
glTexCoord(0.0, 8.0); glVertex(-2.0, 1.0, 0.0)
|
127
|
+
glTexCoord(8.0, 8.0); glVertex(2000.0, 1.0, -6000.0)
|
128
|
+
glTexCoord(8.0, 0.0); glVertex(2000.0, -1.0, -6000.0)
|
129
|
+
glEnd()
|
130
|
+
glutSwapBuffers()
|
129
131
|
end
|
130
132
|
|
131
133
|
myReshape = Proc.new do |w, h|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
134
|
+
glViewport(0, 0, w, h)
|
135
|
+
glMatrixMode(GL_PROJECTION)
|
136
|
+
glLoadIdentity()
|
137
|
+
gluPerspective(60.0, 1.0*w/h, 1.0, 30000.0)
|
138
|
+
glMatrixMode(GL_MODELVIEW)
|
139
|
+
glLoadIdentity()
|
138
140
|
end
|
139
141
|
|
140
142
|
keyboard = Proc.new do |key, x, y|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
143
|
+
case (key)
|
144
|
+
when ?\e
|
145
|
+
exit(0);
|
146
|
+
end
|
145
147
|
end
|
146
148
|
|
147
149
|
glutInit
|
data/examples/RedBook/model.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
|
@@ -37,77 +37,79 @@
|
|
37
37
|
# model.c
|
38
38
|
# This program demonstrates modeling transformations
|
39
39
|
require 'opengl'
|
40
|
+
require 'glu'
|
41
|
+
require 'glut'
|
40
42
|
require 'mathn'
|
41
43
|
include Gl,Glu,Glut
|
42
44
|
|
43
45
|
def init
|
44
|
-
|
45
|
-
|
46
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
47
|
+
glShadeModel(GL_FLAT)
|
46
48
|
end
|
47
49
|
|
48
50
|
def draw_triangle
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
glBegin(GL_LINE_LOOP)
|
52
|
+
glVertex(0.0, 25.0)
|
53
|
+
glVertex(25.0, -25.0)
|
54
|
+
glVertex(-25.0, -25.0)
|
55
|
+
glEnd()
|
54
56
|
end
|
55
57
|
|
56
58
|
display = Proc.new do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
59
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
60
|
+
glColor(1.0, 1.0, 1.0)
|
61
|
+
|
62
|
+
glLoadIdentity()
|
63
|
+
glColor(1.0, 1.0, 1.0)
|
64
|
+
draw_triangle()
|
65
|
+
|
66
|
+
glEnable(GL_LINE_STIPPLE)
|
67
|
+
glLineStipple(1, 0xF0F0)
|
68
|
+
glLoadIdentity()
|
69
|
+
glTranslate(-20.0, 0.0, 0.0)
|
70
|
+
draw_triangle()
|
71
|
+
|
72
|
+
glLineStipple(1, 0xF00F)
|
73
|
+
glLoadIdentity()
|
74
|
+
glScale(1.5, 0.5, 1.0)
|
75
|
+
draw_triangle()
|
76
|
+
|
77
|
+
glLineStipple(1, 0x8888)
|
78
|
+
glLoadIdentity()
|
79
|
+
glRotate(90.0, 0.0, 0.0, 1.0)
|
80
|
+
draw_triangle()
|
81
|
+
glDisable(GL_LINE_STIPPLE)
|
82
|
+
|
83
|
+
glutSwapBuffers()
|
82
84
|
end
|
83
85
|
|
84
86
|
reshape = Proc.new do |w, h|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
87
|
+
glViewport(0, 0, w, h)
|
88
|
+
glMatrixMode(GL_PROJECTION)
|
89
|
+
glLoadIdentity()
|
90
|
+
if (w <= h)
|
91
|
+
glOrtho(-50.0, 50.0, -50.0*h/w, 50.0*h/w, -1.0, 1.0)
|
92
|
+
else
|
93
|
+
glOrtho(-50.0*w/h,50.0*w/h, -50.0, 50.0, -1.0, 1.0)
|
94
|
+
end
|
95
|
+
glMatrixMode(GL_MODELVIEW)
|
94
96
|
end
|
95
97
|
|
96
98
|
keyboard = Proc.new do |key, x, y|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
99
|
+
case key
|
100
|
+
when ?\e
|
101
|
+
exit(0)
|
102
|
+
end
|
101
103
|
end
|
102
104
|
|
103
105
|
# main
|
104
106
|
glutInit()
|
105
107
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
106
|
-
glutInitWindowSize(500, 500)
|
108
|
+
glutInitWindowSize(500, 500)
|
107
109
|
glutInitWindowPosition(100, 100)
|
108
110
|
glutCreateWindow($0)
|
109
111
|
init()
|
110
|
-
glutDisplayFunc(display)
|
112
|
+
glutDisplayFunc(display)
|
111
113
|
glutReshapeFunc(reshape)
|
112
114
|
glutKeyboardFunc(keyboard)
|
113
115
|
glutMainLoop()
|
@@ -1,13 +1,13 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 1993-1997, Silicon Graphics, Inc.
|
3
|
-
# ALL RIGHTS RESERVED
|
4
|
-
# Permission to use, copy, modify, and distribute this software for
|
3
|
+
# ALL RIGHTS RESERVED
|
4
|
+
# Permission to use, copy, modify, and distribute this software for
|
5
5
|
# any purpose and without fee is hereby granted, provided that the above
|
6
6
|
# copyright notice appear in all copies and that both the copyright notice
|
7
|
-
# and this permission notice appear in supporting documentation, and that
|
7
|
+
# and this permission notice appear in supporting documentation, and that
|
8
8
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
9
9
|
# or publicity pertaining to distribution of the software without specific,
|
10
|
-
# written prior permission.
|
10
|
+
# written prior permission.
|
11
11
|
#
|
12
12
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
13
13
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -21,8 +21,8 @@
|
|
21
21
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
22
22
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
23
23
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
24
|
-
#
|
25
|
-
# US Government Users Restricted Rights
|
24
|
+
#
|
25
|
+
# US Government Users Restricted Rights
|
26
26
|
# Use, duplication, or disclosure by the Government is subject to
|
27
27
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
28
28
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -49,6 +49,8 @@
|
|
49
49
|
# The scene is then redrawn with the light in a new position.
|
50
50
|
|
51
51
|
require 'opengl'
|
52
|
+
require 'glu'
|
53
|
+
require 'glut'
|
52
54
|
require 'rational'
|
53
55
|
require 'mathn'
|
54
56
|
include Gl,Glu,Glut
|
@@ -58,11 +60,11 @@ $spin = 0
|
|
58
60
|
# Initialize material property, light source, lighting model,
|
59
61
|
# and depth buffer.
|
60
62
|
def init
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
64
|
+
glShadeModel(GL_SMOOTH)
|
65
|
+
glEnable(GL_LIGHTING)
|
66
|
+
glEnable(GL_LIGHT0)
|
67
|
+
glEnable(GL_DEPTH_TEST)
|
66
68
|
end
|
67
69
|
|
68
70
|
# Here is where the light position is reset after the modeling
|
@@ -70,62 +72,62 @@ end
|
|
70
72
|
# light at a new position in world coordinates. The cube
|
71
73
|
# represents the position of the light.
|
72
74
|
display = Proc.new do
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
75
|
+
position = [ 0.0, 0.0, 1.5, 1.0 ]
|
76
|
+
|
77
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
78
|
+
glPushMatrix()
|
79
|
+
GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
|
80
|
+
|
81
|
+
glPushMatrix()
|
82
|
+
glRotate($spin, 1.0, 0.0, 0.0)
|
83
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
84
|
+
|
85
|
+
glTranslate(0.0, 0.0, 1.5)
|
86
|
+
glDisable(GL_LIGHTING)
|
87
|
+
glColor(0.0, 1.0, 1.0)
|
88
|
+
glutWireCube(0.1)
|
89
|
+
glEnable(GL_LIGHTING)
|
90
|
+
glPopMatrix()
|
91
|
+
|
92
|
+
glutSolidTorus(0.275, 0.85, 8, 15)
|
93
|
+
glPopMatrix()
|
94
|
+
glutSwapBuffers()
|
93
95
|
end
|
94
96
|
|
95
97
|
reshape = Proc.new do |w, h|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
glViewport(0, 0, w, h)
|
99
|
+
glMatrixMode(GL_PROJECTION)
|
100
|
+
glLoadIdentity()
|
101
|
+
gluPerspective(40.0, w/h, 1.0, 20.0)
|
102
|
+
glMatrixMode(GL_MODELVIEW)
|
103
|
+
glLoadIdentity()
|
102
104
|
end
|
103
105
|
|
104
106
|
mouse = Proc.new do |button, state, x, y|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
case button
|
108
|
+
when GLUT_LEFT_BUTTON
|
109
|
+
if (state == GLUT_DOWN)
|
110
|
+
$spin = ($spin + 30) % 360
|
111
|
+
glutPostRedisplay()
|
112
|
+
end
|
113
|
+
end
|
112
114
|
end
|
113
115
|
|
114
116
|
keyboard = Proc.new do |key, x, y|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
case key
|
118
|
+
when ?\e
|
119
|
+
exit(0)
|
120
|
+
end
|
119
121
|
end
|
120
122
|
|
121
123
|
# main
|
122
124
|
glutInit
|
123
125
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
124
|
-
glutInitWindowSize(500, 500)
|
126
|
+
glutInitWindowSize(500, 500)
|
125
127
|
glutInitWindowPosition(100, 100)
|
126
128
|
glutCreateWindow($0)
|
127
129
|
init()
|
128
|
-
glutDisplayFunc(display)
|
130
|
+
glutDisplayFunc(display)
|
129
131
|
glutReshapeFunc(reshape)
|
130
132
|
glutMouseFunc(mouse)
|
131
133
|
glutKeyboardFunc(keyboard)
|