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/surface.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#
|
2
2
|
# (c) Copyright 1993, 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,10 +36,12 @@
|
|
36
36
|
#
|
37
37
|
#
|
38
38
|
# surface.c
|
39
|
-
# This program draws a NURBS surface in the shape of a
|
39
|
+
# This program draws a NURBS surface in the shape of a
|
40
40
|
# symmetrical hill.
|
41
41
|
#
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
$ctlpoints = Array.new(4).collect { Array.new(4).collect { Array.new(3, nil) } } # 4*4*3 array
|
@@ -50,104 +52,104 @@ $theNurb = nil
|
|
50
52
|
# Initializes the control points of the surface to a small hill.
|
51
53
|
# The control points range from -3 to +3 in x, y, and z
|
52
54
|
def init_surface
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
|
55
|
+
for u in 0..3
|
56
|
+
for v in 0..3
|
57
|
+
$ctlpoints[u][v][0] = 2.0*(u - 1.5)
|
58
|
+
$ctlpoints[u][v][1] = 2.0*(v - 1.5)
|
59
|
+
|
60
|
+
if ( (u == 1 || u == 2) && (v == 1 || v == 2))
|
61
|
+
$ctlpoints[u][v][2] = 3
|
62
|
+
else
|
63
|
+
$ctlpoints[u][v][2] = -3
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
67
69
|
# Initialize material property and depth buffer.
|
68
70
|
def myinit
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
71
|
+
mat_diffuse = [ 0.7, 0.7, 0.7, 1.0 ]
|
72
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
73
|
+
mat_shininess = [ 100.0 ]
|
74
|
+
|
75
|
+
glClearColor(0.0, 0.0, 0.0, 1.0)
|
76
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
77
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
78
|
+
glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
|
79
|
+
|
80
|
+
glEnable(GL_LIGHTING)
|
81
|
+
glEnable(GL_LIGHT0)
|
82
|
+
glDepthFunc(GL_LESS)
|
83
|
+
glEnable(GL_DEPTH_TEST)
|
84
|
+
glEnable(GL_AUTO_NORMAL)
|
85
|
+
glEnable(GL_NORMALIZE)
|
86
|
+
|
87
|
+
init_surface()
|
88
|
+
|
89
|
+
$theNurb = gluNewNurbsRenderer()
|
90
|
+
gluNurbsProperty($theNurb, GLU_SAMPLING_TOLERANCE, 25.0)
|
91
|
+
gluNurbsProperty($theNurb, GLU_DISPLAY_MODE, GLU_FILL)
|
90
92
|
end
|
91
93
|
|
92
94
|
display = Proc.new do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
95
|
+
knots = [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
|
96
|
+
|
97
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
98
|
+
|
99
|
+
glPushMatrix()
|
100
|
+
glRotate(330.0, 1.0,0.0,0.0)
|
101
|
+
glScale(0.5, 0.5, 0.5)
|
102
|
+
|
103
|
+
gluBeginSurface($theNurb)
|
104
|
+
gluNurbsSurface($theNurb,
|
105
|
+
8, knots,
|
106
|
+
8, knots,
|
107
|
+
4 * 3,
|
108
|
+
3,
|
109
|
+
$ctlpoints.flatten,
|
110
|
+
4, 4,
|
111
|
+
GL_MAP2_VERTEX_3)
|
112
|
+
gluEndSurface($theNurb)
|
113
|
+
|
114
|
+
if($showPoints==1)
|
115
|
+
glPointSize(5.0)
|
116
|
+
glDisable(GL_LIGHTING)
|
117
|
+
glColor(1.0, 1.0, 0.0)
|
118
|
+
glBegin(GL_POINTS)
|
119
|
+
for i in 0..3
|
120
|
+
for j in 0..3
|
121
|
+
glVertex($ctlpoints[i][j][0], $ctlpoints[i][j][1], $ctlpoints[i][j][2])
|
122
|
+
end
|
123
|
+
end
|
124
|
+
glEnd()
|
125
|
+
glEnable(GL_LIGHTING)
|
126
|
+
end
|
127
|
+
|
128
|
+
glPopMatrix()
|
129
|
+
glutSwapBuffers()
|
128
130
|
end
|
129
131
|
|
130
132
|
reshape = Proc.new do |w, h|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
133
|
+
glViewport(0, 0, w, h)
|
134
|
+
glMatrixMode(GL_PROJECTION)
|
135
|
+
glLoadIdentity()
|
136
|
+
gluPerspective(45.0, w/h, 3.0, 8.0)
|
137
|
+
|
138
|
+
glMatrixMode(GL_MODELVIEW)
|
139
|
+
glLoadIdentity()
|
140
|
+
glTranslate(0.0, 0.0, -5.0)
|
139
141
|
end
|
140
142
|
|
141
143
|
menu = Proc.new do |value|
|
142
|
-
|
143
|
-
|
144
|
+
$showPoints = value
|
145
|
+
glutPostRedisplay()
|
144
146
|
end
|
145
147
|
|
146
148
|
keyboard = Proc.new do |key, x, y|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
149
|
+
case (key)
|
150
|
+
when ?\e
|
151
|
+
exit(0);
|
152
|
+
end
|
151
153
|
end
|
152
154
|
|
153
155
|
glutInit
|
@@ -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
|
@@ -40,85 +40,87 @@
|
|
40
40
|
# This program renders three lighted, shaded teapots, with
|
41
41
|
# different ambient values.
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
# Initialize light source and lighting model.
|
46
48
|
def myinit
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
49
|
+
light_ambient = [0.0, 0.0, 0.0, 1.0]
|
50
|
+
light_diffuse = [1.0, 1.0, 1.0, 1.0]
|
51
|
+
light_specular = [1.0, 1.0, 1.0, 1.0]
|
52
|
+
# light_position is NOT default value
|
53
|
+
light_position = [1.0, 0.0, 0.0, 0.0]
|
54
|
+
global_ambient = [0.75, 0.75, 0.75, 1.0]
|
55
|
+
|
56
|
+
glLight(GL_LIGHT0, GL_AMBIENT, light_ambient)
|
57
|
+
glLight(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
|
58
|
+
glLight(GL_LIGHT0, GL_SPECULAR, light_specular)
|
59
|
+
glLight(GL_LIGHT0, GL_POSITION, light_position)
|
60
|
+
|
61
|
+
glLightModel(GL_LIGHT_MODEL_AMBIENT, global_ambient)
|
62
|
+
|
63
|
+
glFrontFace(GL_CW)
|
64
|
+
glEnable(GL_LIGHTING)
|
65
|
+
glEnable(GL_LIGHT0)
|
66
|
+
glEnable(GL_AUTO_NORMAL)
|
67
|
+
glEnable(GL_NORMALIZE)
|
68
|
+
glDepthFunc(GL_LESS)
|
69
|
+
glEnable(GL_DEPTH_TEST)
|
68
70
|
end
|
69
71
|
|
70
72
|
display = proc do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
73
|
+
low_ambient = [0.1, 0.1, 0.1, 1.0]
|
74
|
+
more_ambient = [0.4, 0.4, 0.4, 1.0]
|
75
|
+
most_ambient = [1.0, 1.0, 1.0, 1.0]
|
76
|
+
|
77
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
78
|
+
|
79
|
+
# material has small ambient reflection
|
80
|
+
glMaterial(GL_FRONT, GL_AMBIENT, low_ambient)
|
81
|
+
glMaterial(GL_FRONT, GL_SHININESS, 40.0)
|
82
|
+
glPushMatrix()
|
83
|
+
glTranslate(0.0, 2.0, 0.0)
|
84
|
+
glutSolidTeapot(1.0)
|
85
|
+
glPopMatrix()
|
86
|
+
|
87
|
+
# material has moderate ambient reflection
|
88
|
+
glMaterial(GL_FRONT, GL_AMBIENT, more_ambient)
|
89
|
+
glPushMatrix()
|
90
|
+
glTranslate(0.0, 0.0, 0.0)
|
91
|
+
glutSolidTeapot(1.0)
|
92
|
+
glPopMatrix()
|
93
|
+
|
94
|
+
# material has large ambient reflection
|
95
|
+
glMaterial(GL_FRONT, GL_AMBIENT, most_ambient)
|
96
|
+
glPushMatrix()
|
97
|
+
glTranslate(0.0, -2.0, 0.0)
|
98
|
+
glutSolidTeapot(1.0)
|
99
|
+
glPopMatrix()
|
100
|
+
glFlush()
|
99
101
|
end
|
100
102
|
|
101
103
|
myReshape = proc do |w, h|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
glViewport(0, 0, w, h)
|
105
|
+
glMatrixMode(GL_PROJECTION)
|
106
|
+
glLoadIdentity()
|
107
|
+
if (w <= h)
|
108
|
+
glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -10.0, 10.0)
|
109
|
+
else
|
110
|
+
glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -10.0, 10.0)
|
111
|
+
end
|
112
|
+
glMatrixMode(GL_MODELVIEW)
|
111
113
|
end
|
112
114
|
|
113
115
|
keyboard = Proc.new do |key, x, y|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
116
|
+
case (key)
|
117
|
+
when ?\e
|
118
|
+
exit(0);
|
119
|
+
end
|
118
120
|
end
|
119
121
|
|
120
122
|
# Main Loop
|
121
|
-
# Open window with initial window size, title bar,
|
123
|
+
# Open window with initial window size, title bar,
|
122
124
|
# RGBA display mode, and handle input events.
|
123
125
|
glutInit()
|
124
126
|
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
|
data/examples/RedBook/teapots.rb
CHANGED
@@ -40,55 +40,57 @@
|
|
40
40
|
# This program demonstrates lots of material properties.
|
41
41
|
# A single light source illuminates the objects.
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
# Initialize depth buffer, projection matrix, light source, and lighting
|
46
48
|
# model. Do not specify a material property here.
|
47
49
|
def myinit
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
50
|
+
ambient = [0.0, 0.0, 0.0, 1.0]
|
51
|
+
diffuse = [1.0, 1.0, 1.0, 1.0]
|
52
|
+
position = [0.0, 3.0, 3.0, 0.0]
|
53
|
+
|
54
|
+
lmodel_ambient = [0.2, 0.2, 0.2, 1.0]
|
55
|
+
local_view = [0.0]
|
56
|
+
|
57
|
+
glLight(GL_LIGHT0, GL_AMBIENT, ambient)
|
58
|
+
glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
|
59
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
60
|
+
glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
|
61
|
+
glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
|
62
|
+
|
63
|
+
glFrontFace(GL_CW)
|
64
|
+
glEnable(GL_LIGHTING)
|
65
|
+
glEnable(GL_LIGHT0)
|
66
|
+
glEnable(GL_AUTO_NORMAL)
|
67
|
+
glEnable(GL_NORMALIZE)
|
68
|
+
glEnable(GL_DEPTH_TEST)
|
69
|
+
glDepthFunc(GL_LESS)
|
68
70
|
end
|
69
71
|
|
70
72
|
# Move object into position. Use 3rd through 12th parameters to specify the
|
71
73
|
# material property. Draw a teapot.
|
72
74
|
def renderTeapot(x, y, ambr, ambg, ambb, difr, difg, difb, specr, specg, specb, shine)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
75
|
+
mat = []
|
76
|
+
glPushMatrix()
|
77
|
+
glTranslate(x, y, 0.0)
|
78
|
+
mat[0] = ambr
|
79
|
+
mat[1] = ambg
|
80
|
+
mat[2] = ambb
|
81
|
+
mat[3] = 1.0
|
82
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat)
|
83
|
+
mat[0] = difr
|
84
|
+
mat[1] = difg
|
85
|
+
mat[2] = difb
|
86
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat)
|
87
|
+
mat[0] = specr
|
88
|
+
mat[1] = specg
|
89
|
+
mat[2] = specb
|
90
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat)
|
91
|
+
glMaterial(GL_FRONT, GL_SHININESS, shine * 128.0)
|
92
|
+
glutSolidTeapot(1.0)
|
93
|
+
glPopMatrix()
|
92
94
|
end
|
93
95
|
|
94
96
|
# First column: emerald, jade, obsidian, pearl, ruby, turquoise
|
@@ -96,76 +98,76 @@ end
|
|
96
98
|
# 3rd column: black, cyan, green, red, white, yellow plastic
|
97
99
|
# 4th column: black, cyan, green, red, white, yellow rubber
|
98
100
|
display = proc do
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
101
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
102
|
+
renderTeapot(2.0, 17.0, 0.0215, 0.1745, 0.0215,
|
103
|
+
0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6)
|
104
|
+
renderTeapot(2.0, 14.0, 0.135, 0.2225, 0.1575,
|
105
|
+
0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1)
|
106
|
+
renderTeapot(2.0, 11.0, 0.05375, 0.05, 0.06625,
|
107
|
+
0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3)
|
108
|
+
renderTeapot(2.0, 8.0, 0.25, 0.20725, 0.20725,
|
109
|
+
1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088)
|
110
|
+
renderTeapot(2.0, 5.0, 0.1745, 0.01175, 0.01175,
|
111
|
+
0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6)
|
112
|
+
renderTeapot(2.0, 2.0, 0.1, 0.18725, 0.1745,
|
113
|
+
0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1)
|
114
|
+
renderTeapot(6.0, 17.0, 0.329412, 0.223529, 0.027451,
|
115
|
+
0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843,
|
116
|
+
0.21794872)
|
117
|
+
renderTeapot(6.0, 14.0, 0.2125, 0.1275, 0.054,
|
118
|
+
0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2)
|
119
|
+
renderTeapot(6.0, 11.0, 0.25, 0.25, 0.25,
|
120
|
+
0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6)
|
121
|
+
renderTeapot(6.0, 8.0, 0.19125, 0.0735, 0.0225,
|
122
|
+
0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1)
|
123
|
+
renderTeapot(6.0, 5.0, 0.24725, 0.1995, 0.0745,
|
124
|
+
0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4)
|
125
|
+
renderTeapot(6.0, 2.0, 0.19225, 0.19225, 0.19225,
|
126
|
+
0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4)
|
127
|
+
renderTeapot(10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01,
|
128
|
+
0.50, 0.50, 0.50, 0.25)
|
129
|
+
renderTeapot(10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392,
|
130
|
+
0.50196078, 0.50196078, 0.50196078, 0.25)
|
131
|
+
renderTeapot(10.0, 11.0, 0.0, 0.0, 0.0,
|
132
|
+
0.1, 0.35, 0.1, 0.45, 0.55, 0.45, 0.25)
|
133
|
+
renderTeapot(10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
|
134
|
+
0.7, 0.6, 0.6, 0.25)
|
135
|
+
renderTeapot(10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55,
|
136
|
+
0.70, 0.70, 0.70, 0.25)
|
137
|
+
renderTeapot(10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0,
|
138
|
+
0.60, 0.60, 0.50, 0.25)
|
139
|
+
renderTeapot(14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01,
|
140
|
+
0.4, 0.4, 0.4, 0.078125)
|
141
|
+
renderTeapot(14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5,
|
142
|
+
0.04, 0.7, 0.7, 0.078125)
|
143
|
+
renderTeapot(14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4,
|
144
|
+
0.04, 0.7, 0.04, 0.078125)
|
145
|
+
renderTeapot(14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4,
|
146
|
+
0.7, 0.04, 0.04, 0.078125)
|
147
|
+
renderTeapot(14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5,
|
148
|
+
0.7, 0.7, 0.7, 0.078125)
|
149
|
+
renderTeapot(14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4,
|
150
|
+
0.7, 0.7, 0.04, 0.078125)
|
151
|
+
glutSwapBuffers()
|
150
152
|
end
|
151
153
|
|
152
154
|
myReshape = proc do |w, h|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
155
|
+
glViewport(0, 0, w, h)
|
156
|
+
glMatrixMode(GL_PROJECTION)
|
157
|
+
glLoadIdentity()
|
158
|
+
if (w <= h)
|
159
|
+
glOrtho(0.0, 16.0, 0.0, 16.0 * h.to_f / w, -10.0, 10.0)
|
160
|
+
else
|
161
|
+
glOrtho(0.0, 16.0 * w.to_f / h, 0.0, 16.0,-10.0, 10.0)
|
162
|
+
end
|
163
|
+
glMatrixMode(GL_MODELVIEW)
|
162
164
|
end
|
163
165
|
|
164
166
|
keyboard = Proc.new do |key, x, y|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
167
|
+
case (key)
|
168
|
+
when ?\e
|
169
|
+
exit(0);
|
170
|
+
end
|
169
171
|
end
|
170
172
|
|
171
173
|
# Main Loop Open window with initial window size, title bar, RGBA display
|