ruby-opengl 0.40.1 → 0.50.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/doc/build_install.txt +48 -28
- data/doc/extensions.txt +361 -0
- data/doc/history.txt +8 -2
- data/doc/requirements_and_design.txt +0 -13
- data/doc/roadmap.txt +11 -13
- data/doc/supplies/page_template.html +11 -5
- data/doc/thanks.txt +2 -4
- data/doc/tutorial.txt +1 -4
- data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
- data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
- data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
- data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -0
- data/examples/NeHe/nehe_lesson36.rb +303 -0
- data/examples/OrangeBook/3Dlabs-License.txt +33 -0
- data/examples/OrangeBook/brick.frag +36 -0
- data/examples/OrangeBook/brick.rb +388 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +424 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +13 -83
- data/examples/RedBook/aaindex.rb +97 -0
- data/examples/RedBook/aapoly.rb +142 -0
- data/examples/RedBook/aargb.rb +119 -0
- data/examples/RedBook/accanti.rb +162 -0
- data/examples/RedBook/accpersp.rb +215 -0
- data/examples/RedBook/alpha.rb +123 -0
- data/examples/RedBook/alpha3D.rb +158 -0
- data/examples/RedBook/bezcurve.rb +105 -0
- data/examples/RedBook/bezmesh.rb +137 -0
- data/examples/RedBook/checker.rb +124 -0
- data/examples/RedBook/clip.rb +95 -0
- data/examples/RedBook/colormat.rb +135 -0
- data/examples/RedBook/cube.rb +69 -0
- data/examples/RedBook/depthcue.rb +99 -0
- data/examples/RedBook/dof.rb +205 -0
- data/examples/{legacy → RedBook}/double.rb +59 -58
- data/examples/{legacy → RedBook}/drawf.rb +47 -54
- data/examples/RedBook/feedback.rb +145 -0
- data/examples/RedBook/fog.rb +167 -0
- data/examples/RedBook/font.rb +151 -0
- data/examples/RedBook/hello.rb +79 -0
- data/examples/RedBook/image.rb +137 -0
- data/examples/{legacy → RedBook}/jitter.rb +60 -62
- data/examples/RedBook/lines.rb +128 -0
- data/examples/RedBook/list.rb +111 -0
- data/examples/RedBook/material.rb +275 -0
- data/examples/RedBook/mipmap.rb +156 -0
- data/examples/{legacy → RedBook}/model.rb +66 -72
- data/examples/{legacy → RedBook}/movelight.rb +67 -75
- data/examples/RedBook/pickdepth.rb +179 -0
- data/examples/{legacy → RedBook}/planet.rb +62 -66
- data/examples/RedBook/quadric.rb +158 -0
- data/examples/RedBook/robot.rb +115 -0
- data/examples/RedBook/select.rb +196 -0
- data/examples/RedBook/smooth.rb +95 -0
- data/examples/RedBook/stencil.rb +163 -0
- data/examples/RedBook/stroke.rb +167 -0
- data/examples/RedBook/surface.rb +166 -0
- data/examples/RedBook/teaambient.rb +132 -0
- data/examples/RedBook/teapots.rb +182 -0
- data/examples/RedBook/tess.rb +183 -0
- data/examples/RedBook/texbind.rb +147 -0
- data/examples/RedBook/texgen.rb +169 -0
- data/examples/RedBook/texturesurf.rb +128 -0
- data/examples/RedBook/varray.rb +159 -0
- data/examples/RedBook/wrap.rb +148 -0
- data/examples/misc/anisotropic.rb +194 -0
- data/examples/misc/font-glut.rb +46 -0
- data/examples/{plane.rb → misc/plane.rb} +0 -0
- data/examples/misc/readpixel.rb +65 -0
- data/examples/{smooth.rb → misc/smooth.rb} +0 -0
- data/examples/{test.rb → misc/test.rb} +0 -0
- data/ext/common/common.h +252 -70
- data/ext/common/gl-enums.h +6102 -7334
- data/ext/common/gl-types.h +47 -0
- data/ext/common/glu-enums.h +469 -0
- data/ext/gl/gl-1.0-1.1.c +842 -2464
- data/ext/gl/gl-1.2.c +217 -281
- data/ext/gl/gl-1.3.c +113 -133
- data/ext/gl/gl-1.4.c +98 -334
- data/ext/gl/gl-1.5.c +28 -34
- data/ext/gl/gl-2.0.c +26 -235
- data/ext/gl/gl-2.1.c +31 -124
- data/ext/gl/gl-enums.c +786 -631
- data/ext/gl/gl-ext-arb.c +66 -0
- data/ext/gl/gl-ext-ext.c +218 -0
- data/ext/gl/gl.c +138 -31
- data/ext/gl/mkrf_conf.rb +1 -0
- data/ext/glu/glu-enums.c +163 -0
- data/ext/glu/glu.c +1003 -1205
- data/ext/glu/mkrf_conf.rb +1 -0
- data/ext/glut/glut.c +1056 -1175
- data/lib/opengl.rb +90 -3
- data/test/tc_common.rb +26 -13
- data/test/tc_ext_arb.rb +73 -0
- data/test/tc_ext_ext.rb +74 -0
- data/test/tc_func_12.rb +8 -8
- data/test/tc_func_13.rb +17 -11
- data/test/tc_func_14.rb +8 -8
- data/test/tc_func_15.rb +190 -2
- data/test/tc_func_20.rb +36 -10
- data/test/tc_func_21.rb +445 -2
- data/test/tc_glu.rb +305 -0
- data/test/tc_misc.rb +1 -0
- metadata +84 -68
- data/doc/screenshots.txt +0 -23
- data/examples/legacy/COPYRIGHT +0 -8
- data/examples/legacy/aaindex.rb +0 -98
- data/examples/legacy/aapoly.rb +0 -153
- data/examples/legacy/aargb.rb +0 -139
- data/examples/legacy/accanti.rb +0 -159
- data/examples/legacy/accpersp.rb +0 -216
- data/examples/legacy/alpha.rb +0 -133
- data/examples/legacy/alpha3D.rb +0 -165
- data/examples/legacy/bezcurve.rb +0 -107
- data/examples/legacy/bezmesh.rb +0 -131
- data/examples/legacy/checker.rb +0 -121
- data/examples/legacy/clip.rb +0 -104
- data/examples/legacy/colormat.rb +0 -145
- data/examples/legacy/cube.rb +0 -73
- data/examples/legacy/depthcue.rb +0 -101
- data/examples/legacy/dof.rb +0 -212
- data/examples/legacy/feedback.rb +0 -152
- data/examples/legacy/fog.rb +0 -172
- data/examples/legacy/font-glut.rb +0 -41
- data/examples/legacy/font.rb +0 -158
- data/examples/legacy/hello.rb +0 -75
- data/examples/legacy/image.rb +0 -145
- data/examples/legacy/lines.rb +0 -135
- data/examples/legacy/list.rb +0 -120
- data/examples/legacy/material.rb +0 -290
- data/examples/legacy/mipmap.rb +0 -159
- data/examples/legacy/pickdepth.rb +0 -180
- data/examples/legacy/quadric.rb +0 -180
- data/examples/legacy/readpixel.rb +0 -59
- data/examples/legacy/robot.rb +0 -120
- data/examples/legacy/select.rb +0 -207
- data/examples/legacy/smooth.rb +0 -41
- data/examples/legacy/stencil.rb +0 -154
- data/examples/legacy/stroke.rb +0 -170
- data/examples/legacy/surface.rb +0 -170
- data/examples/legacy/teaambient.rb +0 -132
- data/examples/legacy/teapots.rb +0 -188
- data/examples/legacy/tess.rb +0 -222
- data/examples/legacy/texbind.rb +0 -157
- data/examples/legacy/texgen.rb +0 -171
- data/examples/legacy/texturesurf.rb +0 -128
- data/examples/legacy/varray.rb +0 -167
- data/examples/legacy/wrap.rb +0 -158
- data/lib/gl_prev.rb +0 -46
- data/lib/glu_prev.rb +0 -46
- data/lib/glut_prev.rb +0 -45
data/examples/legacy/colormat.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
#/*
|
2
|
-
# * Copyright (c) 1993-1997, Silicon Graphics, Inc.
|
3
|
-
# * ALL RIGHTS RESERVED
|
4
|
-
# * Permission to use, copy, modify, and distribute this software for
|
5
|
-
# * any purpose and without fee is hereby granted, provided that the above
|
6
|
-
# * copyright notice appear in all copies and that both the copyright notice
|
7
|
-
# * and this permission notice appear in supporting documentation, and that
|
8
|
-
# * the name of Silicon Graphics, Inc. not be used in advertising
|
9
|
-
# * or publicity pertaining to distribution of the software without specific,
|
10
|
-
# * written prior permission.
|
11
|
-
# *
|
12
|
-
# * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
13
|
-
# * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
14
|
-
# * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
15
|
-
# * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
16
|
-
# * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
17
|
-
# * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
18
|
-
# * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
19
|
-
# * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
20
|
-
# * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
21
|
-
# * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
22
|
-
# * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
23
|
-
# * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
24
|
-
# *
|
25
|
-
# * US Government Users Restricted Rights
|
26
|
-
# * Use, duplication, or disclosure by the Government is subject to
|
27
|
-
# * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
28
|
-
# * (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
29
|
-
# * clause at DFARS 252.227-7013 and/or in similar or successor
|
30
|
-
# * clauses in the FAR or the DOD or NASA FAR Supplement.
|
31
|
-
# * Unpublished-- rights reserved under the copyright laws of the
|
32
|
-
# * United States. Contractor/manufacturer is Silicon Graphics,
|
33
|
-
# * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
34
|
-
# *
|
35
|
-
# * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
|
36
|
-
# */
|
37
|
-
#
|
38
|
-
#/*
|
39
|
-
# * colormat.c
|
40
|
-
# * After initialization, the program will be in
|
41
|
-
# * ColorMaterial mode. Interaction: pressing the
|
42
|
-
# * mouse buttons will change the diffuse reflection values.
|
43
|
-
# */
|
44
|
-
|
45
|
-
require "gl_prev"
|
46
|
-
require "glu_prev"
|
47
|
-
require "glut_prev"
|
48
|
-
require "mathn"
|
49
|
-
|
50
|
-
$diffuseMaterial = [0.5,0.5,0.5,1.0];
|
51
|
-
|
52
|
-
#/* Initialize material property, light source, lighting model,
|
53
|
-
# * and depth buffer.
|
54
|
-
# */
|
55
|
-
def init
|
56
|
-
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];
|
57
|
-
light_position = [ 1.0, 1.0, 1.0, 0.0 ];
|
58
|
-
|
59
|
-
GL.ClearColor(0.0, 0.0, 0.0, 0.0);
|
60
|
-
GL.ShadeModel(GL::SMOOTH);
|
61
|
-
GL.Enable(GL::DEPTH_TEST);
|
62
|
-
GL.Material(GL::FRONT, GL::DIFFUSE, $diffuseMaterial);
|
63
|
-
GL.Material(GL::FRONT, GL::SPECULAR, mat_specular);
|
64
|
-
GL.Material(GL::FRONT, GL::SHININESS, 25.0);
|
65
|
-
GL.Light(GL::LIGHT0, GL::POSITION, light_position);
|
66
|
-
GL.Enable(GL::LIGHTING);
|
67
|
-
GL.Enable(GL::LIGHT0);
|
68
|
-
|
69
|
-
GL.ColorMaterial(GL::FRONT, GL::DIFFUSE);
|
70
|
-
GL.Enable(GL::COLOR_MATERIAL);
|
71
|
-
end
|
72
|
-
|
73
|
-
display = Proc.new {
|
74
|
-
GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
75
|
-
GLUT.SolidSphere(1.0, 20, 16);
|
76
|
-
GL.Flush();
|
77
|
-
}
|
78
|
-
|
79
|
-
reshape = Proc.new {|w, h|
|
80
|
-
GL.Viewport(0, 0, w, h);
|
81
|
-
GL.MatrixMode (GL::PROJECTION);
|
82
|
-
GL.LoadIdentity();
|
83
|
-
if (w <= h)
|
84
|
-
GL.Ortho(-1.5, 1.5, -1.5*h/w, 1.5*h/w, -10.0, 10.0);
|
85
|
-
else
|
86
|
-
GL.Ortho(-1.5*w/h, 1.5*w/h, -1.5, 1.5, -10.0, 10.0);
|
87
|
-
end
|
88
|
-
GL.MatrixMode(GL::MODELVIEW);
|
89
|
-
GL.LoadIdentity();
|
90
|
-
}
|
91
|
-
|
92
|
-
# /* ARGSUSED2 */
|
93
|
-
mouse = Proc.new {|button, state, x, y|
|
94
|
-
case (button)
|
95
|
-
when GLUT::LEFT_BUTTON
|
96
|
-
if (state == GLUT::DOWN)
|
97
|
-
$diffuseMaterial[0] = $diffuseMaterial[0] + 0.1;
|
98
|
-
if ($diffuseMaterial[0] > 1.0)
|
99
|
-
$diffuseMaterial[0] = 0.0;
|
100
|
-
end
|
101
|
-
GL.Color($diffuseMaterial);
|
102
|
-
GLUT.PostRedisplay();
|
103
|
-
end
|
104
|
-
when GLUT::MIDDLE_BUTTON
|
105
|
-
if (state == GLUT::DOWN)
|
106
|
-
$diffuseMaterial[1] = $diffuseMaterial[1] + 0.1;
|
107
|
-
if ($diffuseMaterial[1] > 1.0)
|
108
|
-
$diffuseMaterial[1] = 0.0;
|
109
|
-
end
|
110
|
-
GL.Color($diffuseMaterial);
|
111
|
-
GLUT.PostRedisplay();
|
112
|
-
end
|
113
|
-
when GLUT::RIGHT_BUTTON
|
114
|
-
if (state == GLUT::DOWN)
|
115
|
-
$diffuseMaterial[2] = $diffuseMaterial[2] + 0.1;
|
116
|
-
if ($diffuseMaterial[2] > 1.0)
|
117
|
-
$diffuseMaterial[2] = 0.0;
|
118
|
-
end
|
119
|
-
GL.Color($diffuseMaterial);
|
120
|
-
GLUT.PostRedisplay();
|
121
|
-
end
|
122
|
-
end
|
123
|
-
}
|
124
|
-
|
125
|
-
# /* ARGSUSED1 */
|
126
|
-
keyboard = Proc.new {|key, x, y|
|
127
|
-
case (key)
|
128
|
-
when 27
|
129
|
-
exit(0);
|
130
|
-
end
|
131
|
-
}
|
132
|
-
|
133
|
-
#int main(int argc, char** argv)
|
134
|
-
#{
|
135
|
-
GLUT.Init
|
136
|
-
GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
|
137
|
-
GLUT.InitWindowSize(500, 500);
|
138
|
-
GLUT.InitWindowPosition(100, 100);
|
139
|
-
GLUT.CreateWindow($0);
|
140
|
-
init();
|
141
|
-
GLUT.DisplayFunc(display);
|
142
|
-
GLUT.ReshapeFunc(reshape);
|
143
|
-
GLUT.MouseFunc(mouse);
|
144
|
-
GLUT.KeyboardFunc(keyboard);
|
145
|
-
GLUT.MainLoop();
|
data/examples/legacy/cube.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -rubygems
|
2
|
-
require "gl_prev"
|
3
|
-
require "glu_prev"
|
4
|
-
require "glut_prev"
|
5
|
-
|
6
|
-
|
7
|
-
$light_diffuse = [1.0, 0.0, 0.0, 1.0]
|
8
|
-
$light_position = [1.0, 1.0, 1.0, 0.0]
|
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] ]
|
12
|
-
$faces = [
|
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] ]
|
15
|
-
$v = 0
|
16
|
-
|
17
|
-
def drawBox
|
18
|
-
for i in (0..5)
|
19
|
-
GL.Begin(GL::QUADS);
|
20
|
-
GL.Normal(*($n[i]));
|
21
|
-
# tmp = $v.to_array
|
22
|
-
# GL.Vertex3f(*$v[$faces[i][0]]);
|
23
|
-
# GL.Vertex3f(*$v[$faces[i][1]]);
|
24
|
-
# GL.Vertex3f(*$v[$faces[i][2]]);
|
25
|
-
# GL.Vertex3f(*$v[$faces[i][3]]);
|
26
|
-
GL.Vertex($v[$faces[i][0]]);
|
27
|
-
GL.Vertex($v[$faces[i][1]]);
|
28
|
-
GL.Vertex($v[$faces[i][2]]);
|
29
|
-
GL.Vertex($v[$faces[i][3]]);
|
30
|
-
GL.End()
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
display = Proc.new {
|
35
|
-
GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
36
|
-
drawBox
|
37
|
-
GLUT.SwapBuffers
|
38
|
-
}
|
39
|
-
|
40
|
-
def myinit
|
41
|
-
# $v[0,0] = $v[1,0] = $v[2,0] = $v[3,0] = -1;
|
42
|
-
# $v[4,0] = $v[5,0] = $v[6,0] = $v[7,0] = 1;
|
43
|
-
# $v[0,1] = $v[1,1] = $v[4,1] = $v[5,1] = -1;
|
44
|
-
# $v[2,1] = $v[3,1] = $v[6,1] = $v[7,1] = 1;
|
45
|
-
# $v[0,2] = $v[3,2] = $v[4,2] = $v[7,2] = 1;
|
46
|
-
# $v[1,2] = $v[2,2] = $v[5,2] = $v[6,2] = -1;
|
47
|
-
|
48
|
-
$v = [[-1, -1,1],[-1, -1,-1], [-1,1,-1], [-1,1,1], [1, -1,1],
|
49
|
-
[1, -1,-1], [1, 1,-1], [1,1,1]]
|
50
|
-
|
51
|
-
GL.Light(GL::LIGHT0, GL::DIFFUSE, $light_diffuse);
|
52
|
-
GL.Light(GL::LIGHT0, GL::POSITION, $light_position);
|
53
|
-
GL.Enable(GL::LIGHT0);
|
54
|
-
GL.Enable(GL::LIGHTING);
|
55
|
-
|
56
|
-
GL.Enable(GL::DEPTH_TEST);
|
57
|
-
|
58
|
-
GL.MatrixMode(GL::PROJECTION);
|
59
|
-
GLU.Perspective(40.0, 1.0, 1.0, 10.0);
|
60
|
-
GL.MatrixMode(GL::MODELVIEW);
|
61
|
-
GLU.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
|
62
|
-
|
63
|
-
GL.Translate(0.0, 0.0, -1.0);
|
64
|
-
GL.Rotate(60, 1.0, 0.0, 0.0);
|
65
|
-
GL.Rotate(-20, 0.0, 0.0, 1.0);
|
66
|
-
end
|
67
|
-
|
68
|
-
GLUT.Init
|
69
|
-
GLUT.InitDisplayMode(GLUT::DOUBLE | GLUT::RGB | GLUT::DEPTH);
|
70
|
-
GLUT.CreateWindow("red 3D lighted cube");
|
71
|
-
GLUT.DisplayFunc(display);
|
72
|
-
myinit
|
73
|
-
GLUT.MainLoop();
|
data/examples/legacy/depthcue.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#/* Copyright (c) Mark J. Kilgard, 1994. */
|
3
|
-
#
|
4
|
-
#/*
|
5
|
-
# * (c) Copyright 1993, Silicon Graphics, Inc.
|
6
|
-
# * ALL RIGHTS RESERVED
|
7
|
-
# * Permission to use, copy, modify, and distribute this software for
|
8
|
-
# * any purpose and without fee is hereby granted, provided that the above
|
9
|
-
# * copyright notice appear in all copies and that both the copyright notice
|
10
|
-
# * and this permission notice appear in supporting documentation, and that
|
11
|
-
# * the name of Silicon Graphics, Inc. not be used in advertising
|
12
|
-
# * or publicity pertaining to distribution of the software without specific,
|
13
|
-
# * written prior permission.
|
14
|
-
# *
|
15
|
-
# * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
16
|
-
# * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
17
|
-
# * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
18
|
-
# * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
19
|
-
# * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
20
|
-
# * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
21
|
-
# * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
22
|
-
# * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
23
|
-
# * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
24
|
-
# * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
25
|
-
# * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
26
|
-
# * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
27
|
-
# *
|
28
|
-
# * US Government Users Restricted Rights
|
29
|
-
# * Use, duplication, or disclosure by the Government is subject to
|
30
|
-
# * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
31
|
-
# * (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
32
|
-
# * clause at DFARS 252.227-7013 and/or in similar or successor
|
33
|
-
# * clauses in the FAR or the DOD or NASA FAR Supplement.
|
34
|
-
# * Unpublished-- rights reserved under the copyright laws of the
|
35
|
-
# * United States. Contractor/manufacturer is Silicon Graphics,
|
36
|
-
# * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
37
|
-
# *
|
38
|
-
# * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
39
|
-
# */
|
40
|
-
#/*
|
41
|
-
# * depthcue.c
|
42
|
-
# * This program draws a wireframe model, which uses
|
43
|
-
# * intensity (brightness) to give clues to distance.
|
44
|
-
# * Fog is used to achieve this effect.
|
45
|
-
# */
|
46
|
-
require "gl_prev"
|
47
|
-
require "glu_prev"
|
48
|
-
require "glut_prev"
|
49
|
-
require "mathn"
|
50
|
-
|
51
|
-
#/* Initialize linear fog for depth cueing.
|
52
|
-
# */
|
53
|
-
def myinit
|
54
|
-
fogColor = [0.0, 0.0, 0.0, 1.0];
|
55
|
-
|
56
|
-
GL.Enable(GL::FOG);
|
57
|
-
GL.Fog(GL::FOG_MODE, GL::LINEAR);
|
58
|
-
GL.Hint(GL::FOG_HINT, GL::NICEST); #/* per pixel */
|
59
|
-
GL.Fog(GL::FOG_START, 3.0);
|
60
|
-
GL.Fog(GL::FOG_END, 5.0);
|
61
|
-
GL.Fog(GL::FOG_COLOR, fogColor);
|
62
|
-
GL.ClearColor(0.0, 0.0, 0.0, 1.0);
|
63
|
-
|
64
|
-
GL.DepthFunc(GL::LESS);
|
65
|
-
GL.Enable(GL::DEPTH_TEST);
|
66
|
-
GL.ShadeModel(GL::FLAT);
|
67
|
-
end
|
68
|
-
|
69
|
-
#/* display() draws an icosahedron.
|
70
|
-
# */
|
71
|
-
display = Proc.new {
|
72
|
-
GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
73
|
-
GL.Color(1.0, 1.0, 1.0);
|
74
|
-
GLUT.WireIcosahedron();
|
75
|
-
GL.Flush();
|
76
|
-
}
|
77
|
-
|
78
|
-
myReshape = Proc.new {|w, h|
|
79
|
-
GL.Viewport(0, 0, w, h);
|
80
|
-
GL.MatrixMode(GL::PROJECTION);
|
81
|
-
GL.LoadIdentity();
|
82
|
-
GLU.Perspective(45.0, w/h, 3.0, 5.0);
|
83
|
-
GL.MatrixMode(GL::MODELVIEW);
|
84
|
-
GL.LoadIdentity();
|
85
|
-
GL.Translate(0.0, 0.0, -4.0); #/* move object into view */
|
86
|
-
}
|
87
|
-
|
88
|
-
#/* Main Loop
|
89
|
-
# */
|
90
|
-
#int main(int argc, char** argv)
|
91
|
-
#{
|
92
|
-
GLUT.Init
|
93
|
-
GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
|
94
|
-
GLUT.CreateWindow($0);
|
95
|
-
myinit();
|
96
|
-
GLUT.ReshapeFunc(myReshape);
|
97
|
-
GLUT.DisplayFunc(display);
|
98
|
-
GLUT.MainLoop();
|
99
|
-
# return 0; /* ANSI C requires main to return int. */
|
100
|
-
#}
|
101
|
-
|
data/examples/legacy/dof.rb
DELETED
@@ -1,212 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#/* Copyright (c) Mark J. Kilgard, 1994. */
|
3
|
-
#
|
4
|
-
#/*
|
5
|
-
# * (c) Copyright 1993, Silicon Graphics, Inc.
|
6
|
-
# * ALL RIGHTS RESERVED
|
7
|
-
# * Permission to use, copy, modify, and distribute this software for
|
8
|
-
# * any purpose and without fee is hereby granted, provided that the above
|
9
|
-
# * copyright notice appear in all copies and that both the copyright notice
|
10
|
-
# * and this permission notice appear in supporting documentation, and that
|
11
|
-
# * the name of Silicon Graphics, Inc. not be used in advertising
|
12
|
-
# * or publicity pertaining to distribution of the software without specific,
|
13
|
-
# * written prior permission.
|
14
|
-
# *
|
15
|
-
# * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
16
|
-
# * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
17
|
-
# * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
18
|
-
# * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
19
|
-
# * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
20
|
-
# * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
21
|
-
# * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
22
|
-
# * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
23
|
-
# * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
24
|
-
# * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
25
|
-
# * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
26
|
-
# * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
27
|
-
# *
|
28
|
-
# * US Government Users Restricted Rights
|
29
|
-
# * Use, duplication, or disclosure by the Government is subject to
|
30
|
-
# * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
31
|
-
# * (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
32
|
-
# * clause at DFARS 252.227-7013 and/or in similar or successor
|
33
|
-
# * clauses in the FAR or the DOD or NASA FAR Supplement.
|
34
|
-
# * Unpublished-- rights reserved under the copyright laws of the
|
35
|
-
# * United States. Contractor/manufacturer is Silicon Graphics,
|
36
|
-
# * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
37
|
-
# *
|
38
|
-
# * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
39
|
-
# */
|
40
|
-
#/*
|
41
|
-
# * dof.c
|
42
|
-
# * This program demonstrates use of the accumulation buffer to
|
43
|
-
# * create an out-of-focus depth-of-field effect. The teapots
|
44
|
-
# * are drawn several times into the accumulation buffer. The
|
45
|
-
# * viewing volume is jittered, except at the focal point, where
|
46
|
-
# * the viewing volume is at the same position, each time. In
|
47
|
-
# * this case, the gold teapot remains in focus.
|
48
|
-
# */
|
49
|
-
require "gl_prev"
|
50
|
-
require "glu_prev"
|
51
|
-
require "glut_prev"
|
52
|
-
require "jitter"
|
53
|
-
|
54
|
-
PI_=3.14159265358979323846
|
55
|
-
|
56
|
-
#/* accFrustum()
|
57
|
-
# * The first 6 arguments are identical to the glFrustum() call.
|
58
|
-
# *
|
59
|
-
# * pixdx and pixdy are anti-alias jitter in pixels.
|
60
|
-
# * Set both equal to 0.0 for no anti-alias jitter.
|
61
|
-
# * eyedx and eyedy are depth-of field jitter in pixels.
|
62
|
-
# * Set both equal to 0.0 for no depth of field effects.
|
63
|
-
# *
|
64
|
-
# * focus is distance from eye to plane in focus.
|
65
|
-
# * focus must be greater than, but not equal to 0.0.
|
66
|
-
# *
|
67
|
-
# * Note that accFrustum() calls glTranslatef(). You will
|
68
|
-
# * probably want to insure that your ModelView matrix has been
|
69
|
-
# * initialized to identity before calling accFrustum().
|
70
|
-
# */
|
71
|
-
def accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
72
|
-
|
73
|
-
viewport = GL::GetDoublev(GL::VIEWPORT);
|
74
|
-
|
75
|
-
xwsize = right - left;
|
76
|
-
ywsize = top - bottom;
|
77
|
-
|
78
|
-
dx = -(pixdx*xwsize/viewport[2] + eyedx*nnear/focus);
|
79
|
-
dy = -(pixdy*ywsize/viewport[3] + eyedy*nnear/focus);
|
80
|
-
|
81
|
-
GL::MatrixMode(GL::PROJECTION);
|
82
|
-
GL::LoadIdentity();
|
83
|
-
GL::Frustum(left + dx, right + dx, bottom + dy, top + dy, nnear, ffar);
|
84
|
-
GL::MatrixMode(GL::MODELVIEW);
|
85
|
-
GL::LoadIdentity();
|
86
|
-
GL::Translate(-eyedx, -eyedy, 0.0);
|
87
|
-
end
|
88
|
-
|
89
|
-
#/* accPerspective()
|
90
|
-
# *
|
91
|
-
# * The first 4 arguments are identical to the gluPerspective() call.
|
92
|
-
# * pixdx and pixdy are anti-alias jitter in pixels.
|
93
|
-
# * Set both equal to 0.0 for no anti-alias jitter.
|
94
|
-
# * eyedx and eyedy are depth-of field jitter in pixels.
|
95
|
-
# * Set both equal to 0.0 for no depth of field effects.
|
96
|
-
# *
|
97
|
-
# * focus is distance from eye to plane in focus.
|
98
|
-
# * focus must be greater than, but not equal to 0.0.
|
99
|
-
# *
|
100
|
-
# * Note that accPerspective() calls accFrustum().
|
101
|
-
# */
|
102
|
-
def accPerspective(fovy, aspect, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
|
103
|
-
fov2 = ((fovy*PI_) / 180.0) / 2.0;
|
104
|
-
|
105
|
-
top = nnear / (Math::cos(fov2) / Math::sin(fov2));
|
106
|
-
bottom = -top;
|
107
|
-
|
108
|
-
right = top * aspect;
|
109
|
-
left = -right;
|
110
|
-
|
111
|
-
accFrustum(left, right, bottom, top, nnear, ffar,
|
112
|
-
pixdx, pixdy, eyedx, eyedy, focus);
|
113
|
-
end
|
114
|
-
|
115
|
-
|
116
|
-
def myinit
|
117
|
-
ambient = [ 0.0, 0.0, 0.0, 1.0 ];
|
118
|
-
diffuse = [ 1.0, 1.0, 1.0, 1.0 ];
|
119
|
-
position = [ 0.0, 3.0, 3.0, 0.0 ];
|
120
|
-
|
121
|
-
lmodel_ambient = [ 0.2, 0.2, 0.2, 1.0 ];
|
122
|
-
local_view = [ 0.0 ];
|
123
|
-
|
124
|
-
GL::Enable(GL::DEPTH_TEST);
|
125
|
-
GL::DepthFunc(GL::LESS);
|
126
|
-
|
127
|
-
GL::Light(GL::LIGHT0, GL::AMBIENT, ambient);
|
128
|
-
GL::Light(GL::LIGHT0, GL::DIFFUSE, diffuse);
|
129
|
-
GL::Light(GL::LIGHT0, GL::POSITION, position);
|
130
|
-
|
131
|
-
GL::LightModel(GL::LIGHT_MODEL_AMBIENT, lmodel_ambient);
|
132
|
-
GL::LightModel(GL::LIGHT_MODEL_LOCAL_VIEWER, local_view);
|
133
|
-
|
134
|
-
GL::FrontFace(GL::CW);
|
135
|
-
GL::Enable(GL::LIGHTING);
|
136
|
-
GL::Enable(GL::LIGHT0);
|
137
|
-
GL::Enable(GL::AUTO_NORMAL);
|
138
|
-
GL::Enable(GL::NORMALIZE);
|
139
|
-
|
140
|
-
GL::MatrixMode(GL::MODELVIEW);
|
141
|
-
GL::LoadIdentity();
|
142
|
-
|
143
|
-
GL::ClearColor(0.0, 0.0, 0.0, 0.0);
|
144
|
-
GL::ClearAccum(0.0, 0.0, 0.0, 0.0);
|
145
|
-
end
|
146
|
-
|
147
|
-
def renderTeapot (x, y, z, ambr, ambg, ambb, difr, difg, difb, specr, specg, specb, shine)
|
148
|
-
GL::PushMatrix();
|
149
|
-
GL::Translate(x, y, z);
|
150
|
-
mat = []
|
151
|
-
mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0;
|
152
|
-
GL::Material(GL::FRONT, GL::AMBIENT, mat);
|
153
|
-
mat[0] = difr; mat[1] = difg; mat[2] = difb;
|
154
|
-
GL::Material(GL::FRONT, GL::DIFFUSE, mat);
|
155
|
-
mat[0] = specr; mat[1] = specg; mat[2] = specb;
|
156
|
-
GL::Material(GL::FRONT, GL::SPECULAR, mat);
|
157
|
-
GL::Material(GL::FRONT, GL::SHININESS, shine*128.0);
|
158
|
-
GLUT::SolidTeapot(0.5);
|
159
|
-
GL::PopMatrix();
|
160
|
-
end
|
161
|
-
|
162
|
-
#/* display() draws 5 teapots into the accumulation buffer
|
163
|
-
# * several times; each time with a jittered perspective.
|
164
|
-
# * The focal point is at z = 5.0, so the gold teapot will
|
165
|
-
# * stay in focus. The amount of jitter is adjusted by the
|
166
|
-
# * magnitude of the accPerspective() jitter; in this example, 0.33.
|
167
|
-
# * In this example, the teapots are drawn 8 times. See jitter.h
|
168
|
-
# */
|
169
|
-
display = proc {
|
170
|
-
viewport = GL::GetDoublev(GL::VIEWPORT);
|
171
|
-
GL::Clear(GL::ACCUM_BUFFER_BIT);
|
172
|
-
|
173
|
-
for jitter in 0...8
|
174
|
-
GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
175
|
-
accPerspective(45.0,
|
176
|
-
viewport[2]/ viewport[3],
|
177
|
-
1.0, 15.0, 0.0, 0.0,
|
178
|
-
0.33*$j8[jitter][0], 0.33*$j8[jitter][1], 5.0);
|
179
|
-
#/* ruby, gold, silver, emerald, and cyan teapots */
|
180
|
-
renderTeapot(-1.1, -0.5, -4.5, 0.1745, 0.01175, 0.01175,
|
181
|
-
0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6);
|
182
|
-
renderTeapot(-0.5, -0.5, -5.0, 0.24725, 0.1995, 0.0745,
|
183
|
-
0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4);
|
184
|
-
renderTeapot(0.2, -0.5, -5.5, 0.19225, 0.19225, 0.19225,
|
185
|
-
0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4);
|
186
|
-
renderTeapot(1.0, -0.5, -6.0, 0.0215, 0.1745, 0.0215,
|
187
|
-
0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6);
|
188
|
-
renderTeapot(1.8, -0.5, -6.5, 0.0, 0.1, 0.06, 0.0, 0.50980392,
|
189
|
-
0.50980392, 0.50196078, 0.50196078, 0.50196078, 0.25);
|
190
|
-
GL::Accum(GL::ACCUM, 0.125);
|
191
|
-
end
|
192
|
-
|
193
|
-
GL::Accum(GL::RETURN, 1.0);
|
194
|
-
GL::Flush();
|
195
|
-
}
|
196
|
-
|
197
|
-
myReshape = proc {|w, h|
|
198
|
-
GL::Viewport(0, 0, w, h);
|
199
|
-
}
|
200
|
-
|
201
|
-
#/* Main Loop
|
202
|
-
# * Open window with initial window size, title bar,
|
203
|
-
# * RGBA display mode, depth buffer, and handle input events.
|
204
|
-
# */
|
205
|
-
GLUT::Init();
|
206
|
-
GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::ACCUM | GLUT::DEPTH);
|
207
|
-
GLUT::CreateWindow()
|
208
|
-
myinit();
|
209
|
-
GLUT::ReshapeFunc(myReshape);
|
210
|
-
GLUT::DisplayFunc(display);
|
211
|
-
GLUT::MainLoop();
|
212
|
-
|