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/clip.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,59 +37,61 @@
|
|
37
37
|
# clip.c
|
38
38
|
# This program demonstrates arbitrary clipping planes.
|
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
|
display = Proc.new do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
51
|
+
eqn = [0.0, 1.0, 0.0, 0.0]
|
52
|
+
eqn2 = [1.0, 0.0, 0.0, 0.0]
|
53
|
+
|
54
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
55
|
+
|
56
|
+
glColor(1.0, 1.0, 1.0)
|
57
|
+
glPushMatrix()
|
58
|
+
glTranslate(0.0, 0.0, -5.0)
|
59
|
+
|
60
|
+
# clip lower half -- y < 0
|
61
|
+
glClipPlane(GL_CLIP_PLANE0, eqn)
|
62
|
+
glEnable(GL_CLIP_PLANE0)
|
63
|
+
# clip left half -- x < 0
|
64
|
+
glClipPlane(GL_CLIP_PLANE1, eqn2)
|
65
|
+
glEnable(GL_CLIP_PLANE1)
|
66
|
+
|
67
|
+
glRotate(90.0, 1.0, 0.0, 0.0)
|
68
|
+
glutWireSphere(1.0, 20, 16)
|
69
|
+
glPopMatrix()
|
70
|
+
glutSwapBuffers()
|
69
71
|
end
|
70
72
|
|
71
73
|
reshape = Proc.new do |w, h|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
glViewport(0, 0, w, h)
|
75
|
+
glMatrixMode(GL_PROJECTION)
|
76
|
+
glLoadIdentity()
|
77
|
+
gluPerspective(60.0, w/ h, 1.0, 20.0)
|
78
|
+
glMatrixMode(GL_MODELVIEW)
|
77
79
|
end
|
78
80
|
|
79
81
|
keyboard = Proc.new do |key, x, y|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
case (key)
|
83
|
+
when ?\e
|
84
|
+
exit(0)
|
85
|
+
end
|
84
86
|
end
|
85
87
|
|
86
88
|
glutInit
|
87
89
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
88
|
-
glutInitWindowSize(500, 500)
|
90
|
+
glutInitWindowSize(500, 500)
|
89
91
|
glutInitWindowPosition(100, 100)
|
90
92
|
glutCreateWindow($0)
|
91
93
|
init()
|
92
|
-
glutDisplayFunc(display)
|
94
|
+
glutDisplayFunc(display)
|
93
95
|
glutReshapeFunc(reshape)
|
94
96
|
glutKeyboardFunc(keyboard)
|
95
97
|
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
|
@@ -36,9 +36,11 @@
|
|
36
36
|
#
|
37
37
|
# colormat.c
|
38
38
|
# After initialization, the program will be in
|
39
|
-
# ColorMaterial mode. Interaction: pressing the
|
39
|
+
# ColorMaterial mode. Interaction: pressing the
|
40
40
|
# mouse buttons will change the diffuse reflection values.
|
41
41
|
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
42
44
|
require 'mathn'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
@@ -47,88 +49,88 @@ $diffuseMaterial = [0.5,0.5,0.5,1.0]
|
|
47
49
|
# Initialize material property, light source, lighting model,
|
48
50
|
# and depth buffer.
|
49
51
|
def init
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
53
|
+
light_position = [ 1.0, 1.0, 1.0, 0.0 ]
|
54
|
+
|
55
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
56
|
+
glShadeModel(GL_SMOOTH)
|
57
|
+
glEnable(GL_DEPTH_TEST)
|
58
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, $diffuseMaterial)
|
59
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
60
|
+
glMaterial(GL_FRONT, GL_SHININESS, 25.0)
|
61
|
+
glLight(GL_LIGHT0, GL_POSITION, light_position)
|
62
|
+
glEnable(GL_LIGHTING)
|
63
|
+
glEnable(GL_LIGHT0)
|
64
|
+
|
65
|
+
glColorMaterial(GL_FRONT, GL_DIFFUSE)
|
66
|
+
glEnable(GL_COLOR_MATERIAL)
|
65
67
|
end
|
66
68
|
|
67
69
|
display = Proc.new do
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
71
|
+
glutSolidSphere(1.0, 20, 16)
|
72
|
+
glutSwapBuffers()
|
71
73
|
end
|
72
74
|
|
73
75
|
reshape = Proc.new do |w, h|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
glViewport(0, 0, w, h)
|
77
|
+
glMatrixMode(GL_PROJECTION)
|
78
|
+
glLoadIdentity()
|
79
|
+
if (w <= h)
|
80
|
+
glOrtho(-1.5, 1.5, -1.5*h/w, 1.5*h/w, -10.0, 10.0)
|
81
|
+
else
|
82
|
+
glOrtho(-1.5*w/h, 1.5*w/h, -1.5, 1.5, -10.0, 10.0)
|
83
|
+
end
|
84
|
+
glMatrixMode(GL_MODELVIEW)
|
85
|
+
glLoadIdentity()
|
84
86
|
end
|
85
87
|
|
86
88
|
mouse = Proc.new do |button, state, x, y|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
89
|
+
case (button)
|
90
|
+
when GLUT_LEFT_BUTTON
|
91
|
+
if (state == GLUT_DOWN)
|
92
|
+
$diffuseMaterial[0] = $diffuseMaterial[0] + 0.1
|
93
|
+
if ($diffuseMaterial[0] > 1.0)
|
94
|
+
$diffuseMaterial[0] = 0.0
|
95
|
+
end
|
96
|
+
glColor($diffuseMaterial)
|
97
|
+
glutPostRedisplay()
|
98
|
+
end
|
99
|
+
when GLUT_MIDDLE_BUTTON
|
100
|
+
if (state == GLUT_DOWN)
|
101
|
+
$diffuseMaterial[1] = $diffuseMaterial[1] + 0.1
|
102
|
+
if ($diffuseMaterial[1] > 1.0)
|
103
|
+
$diffuseMaterial[1] = 0.0
|
104
|
+
end
|
105
|
+
glColor($diffuseMaterial)
|
106
|
+
glutPostRedisplay()
|
107
|
+
end
|
108
|
+
when GLUT_RIGHT_BUTTON
|
109
|
+
if (state == GLUT_DOWN)
|
110
|
+
$diffuseMaterial[2] = $diffuseMaterial[2] + 0.1
|
111
|
+
if ($diffuseMaterial[2] > 1.0)
|
112
|
+
$diffuseMaterial[2] = 0.0
|
113
|
+
end
|
114
|
+
glColor($diffuseMaterial)
|
115
|
+
glutPostRedisplay()
|
116
|
+
end
|
117
|
+
end
|
116
118
|
end
|
117
119
|
|
118
120
|
keyboard = Proc.new do |key, x, y|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
121
|
+
case (key)
|
122
|
+
when ?\e
|
123
|
+
exit(0)
|
124
|
+
end
|
123
125
|
end
|
124
126
|
|
125
127
|
glutInit
|
126
128
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
127
|
-
glutInitWindowSize(500, 500)
|
129
|
+
glutInitWindowSize(500, 500)
|
128
130
|
glutInitWindowPosition(100, 100)
|
129
131
|
glutCreateWindow($0)
|
130
132
|
init()
|
131
|
-
glutDisplayFunc(display)
|
133
|
+
glutDisplayFunc(display)
|
132
134
|
glutReshapeFunc(reshape)
|
133
135
|
glutMouseFunc(mouse)
|
134
136
|
glutKeyboardFunc(keyboard)
|
data/examples/RedBook/cube.rb
CHANGED
@@ -1,61 +1,63 @@
|
|
1
1
|
#!/usr/bin/env ruby -rubygems
|
2
2
|
require 'opengl'
|
3
|
+
require 'glu'
|
4
|
+
require 'glut'
|
3
5
|
include Gl,Glu,Glut
|
4
6
|
|
5
7
|
$light_diffuse = [1.0, 0.0, 0.0, 1.0]
|
6
8
|
$light_position = [1.0, 1.0, 1.0, 0.0]
|
7
|
-
$n = [
|
8
|
-
|
9
|
-
|
9
|
+
$n = [
|
10
|
+
[-1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 0.0, 0.0],
|
11
|
+
[0.0, -1.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.0, -1.0] ]
|
10
12
|
$faces = [
|
11
|
-
|
12
|
-
|
13
|
+
[0, 1, 2, 3], [3, 2, 6, 7], [7, 6, 5, 4],
|
14
|
+
[4, 5, 1, 0], [5, 6, 2, 1], [7, 4, 0, 3] ]
|
13
15
|
$v = 0
|
14
16
|
|
15
17
|
def drawBox
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
for i in (0..5)
|
19
|
+
glBegin(GL_QUADS)
|
20
|
+
glNormal(*($n[i]))
|
21
|
+
glVertex($v[$faces[i][0]])
|
22
|
+
glVertex($v[$faces[i][1]])
|
23
|
+
glVertex($v[$faces[i][2]])
|
24
|
+
glVertex($v[$faces[i][3]])
|
25
|
+
glEnd()
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
display = Proc.new do
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
31
|
+
drawBox
|
32
|
+
glutSwapBuffers
|
31
33
|
end
|
32
34
|
|
33
35
|
def myinit
|
34
36
|
$v = [[-1, -1,1],[-1, -1,-1], [-1,1,-1], [-1,1,1], [1, -1,1],
|
35
|
-
|
37
|
+
[1, -1,-1], [1, 1,-1], [1,1,1]]
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
glLight(GL_LIGHT0, GL_DIFFUSE, $light_diffuse)
|
40
|
+
glLight(GL_LIGHT0, GL_POSITION, $light_position)
|
41
|
+
glEnable(GL_LIGHT0)
|
42
|
+
glEnable(GL_LIGHTING)
|
43
|
+
|
44
|
+
glEnable(GL_DEPTH_TEST)
|
45
|
+
|
46
|
+
glMatrixMode(GL_PROJECTION)
|
47
|
+
gluPerspective(40.0, 1.0, 1.0, 10.0)
|
48
|
+
glMatrixMode(GL_MODELVIEW)
|
49
|
+
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
|
50
|
+
|
51
|
+
glTranslate(0.0, 0.0, -1.0)
|
52
|
+
glRotate(60, 1.0, 0.0, 0.0)
|
53
|
+
glRotate(-20, 0.0, 0.0, 1.0)
|
52
54
|
end
|
53
55
|
|
54
56
|
keyboard = Proc.new do |key, x, y|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
case (key)
|
58
|
+
when ?\e
|
59
|
+
exit(0);
|
60
|
+
end
|
59
61
|
end
|
60
62
|
|
61
63
|
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
|
@@ -37,53 +37,55 @@
|
|
37
37
|
# OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
38
38
|
#
|
39
39
|
# depthcue.c
|
40
|
-
# This program draws a wireframe model, which uses
|
40
|
+
# This program draws a wireframe model, which uses
|
41
41
|
# intensity (brightness) to give clues to distance.
|
42
42
|
# Fog is used to achieve this effect.
|
43
43
|
require 'opengl'
|
44
|
+
require 'glu'
|
45
|
+
require 'glut'
|
44
46
|
require 'mathn'
|
45
47
|
include Gl,Glu,Glut
|
46
48
|
|
47
49
|
# Initialize linear fog for depth cueing.
|
48
50
|
def myinit
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
51
|
+
fogColor = [0.0, 0.0, 0.0, 1.0]
|
52
|
+
|
53
|
+
glEnable(GL_FOG)
|
54
|
+
glFog(GL_FOG_MODE, GL_LINEAR)
|
55
|
+
glHint(GL_FOG_HINT, GL_NICEST) # per pixel
|
56
|
+
glFog(GL_FOG_START, 3.0)
|
57
|
+
glFog(GL_FOG_END, 5.0)
|
58
|
+
glFog(GL_FOG_COLOR, fogColor)
|
59
|
+
glClearColor(0.0, 0.0, 0.0, 1.0)
|
60
|
+
|
61
|
+
glDepthFunc(GL_LESS)
|
62
|
+
glEnable(GL_DEPTH_TEST)
|
63
|
+
glShadeModel(GL_FLAT)
|
62
64
|
end
|
63
65
|
|
64
66
|
# display() draws an icosahedron.
|
65
67
|
display = Proc.new do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
69
|
+
glColor(1.0, 1.0, 1.0)
|
70
|
+
glutWireIcosahedron()
|
71
|
+
glFlush()
|
70
72
|
end
|
71
73
|
|
72
74
|
myReshape = Proc.new do |w, h|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
glViewport(0, 0, w, h)
|
76
|
+
glMatrixMode(GL_PROJECTION)
|
77
|
+
glLoadIdentity()
|
78
|
+
gluPerspective(45.0, w/h, 3.0, 5.0)
|
79
|
+
glMatrixMode(GL_MODELVIEW)
|
80
|
+
glLoadIdentity()
|
81
|
+
glTranslate(0.0, 0.0, -4.0) # move object into view
|
80
82
|
end
|
81
83
|
|
82
84
|
keyboard = Proc.new do |key, x, y|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
85
|
+
case (key)
|
86
|
+
when ?\e
|
87
|
+
exit(0)
|
88
|
+
end
|
87
89
|
end
|
88
90
|
|
89
91
|
# Main Loop
|