ruby-opengl 0.33.0 → 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +42 -15
- data/doc/build_install.txt +70 -25
- data/doc/history.txt +4 -0
- data/doc/requirements_and_design.txt +2 -3
- data/doc/roadmap.txt +15 -2
- data/doc/screenshots.txt +23 -0
- data/doc/supplies/page_template.html +2 -1
- data/doc/thanks.txt +3 -0
- data/doc/tutorial.txt +5 -3
- data/examples/README +57 -7
- data/examples/legacy/COPYRIGHT +8 -0
- data/examples/{aaindex.rb → legacy/aaindex.rb} +6 -5
- data/examples/legacy/aapoly.rb +153 -0
- data/examples/legacy/aargb.rb +139 -0
- data/examples/legacy/accanti.rb +159 -0
- data/examples/legacy/accpersp.rb +216 -0
- data/examples/legacy/alpha.rb +133 -0
- data/examples/legacy/alpha3D.rb +165 -0
- data/examples/legacy/bezcurve.rb +107 -0
- data/examples/legacy/bezmesh.rb +131 -0
- data/examples/legacy/checker.rb +121 -0
- data/examples/legacy/clip.rb +104 -0
- data/examples/legacy/colormat.rb +145 -0
- data/examples/legacy/cube.rb +73 -0
- data/examples/legacy/depthcue.rb +101 -0
- data/examples/legacy/dof.rb +212 -0
- data/examples/legacy/double.rb +104 -0
- data/examples/legacy/drawf.rb +98 -0
- data/examples/legacy/feedback.rb +152 -0
- data/examples/legacy/fog.rb +172 -0
- data/examples/legacy/font-glut.rb +41 -0
- data/examples/legacy/font.rb +158 -0
- data/examples/legacy/hello.rb +75 -0
- data/examples/legacy/image.rb +145 -0
- data/examples/legacy/jitter.rb +209 -0
- data/examples/legacy/lines.rb +135 -0
- data/examples/legacy/list.rb +120 -0
- data/examples/legacy/material.rb +290 -0
- data/examples/legacy/mipmap.rb +159 -0
- data/examples/legacy/model.rb +119 -0
- data/examples/legacy/movelight.rb +140 -0
- data/examples/legacy/pickdepth.rb +180 -0
- data/examples/legacy/planet.rb +112 -0
- data/examples/legacy/quadric.rb +180 -0
- data/examples/legacy/readpixel.rb +59 -0
- data/examples/legacy/robot.rb +120 -0
- data/examples/legacy/select.rb +207 -0
- data/examples/{smooth_prev.rb → legacy/smooth.rb} +3 -2
- data/examples/legacy/stencil.rb +154 -0
- data/examples/legacy/stroke.rb +170 -0
- data/examples/legacy/surface.rb +170 -0
- data/examples/legacy/teaambient.rb +132 -0
- data/examples/legacy/teapots.rb +188 -0
- data/examples/legacy/tess.rb +222 -0
- data/examples/legacy/texbind.rb +157 -0
- data/examples/legacy/texgen.rb +171 -0
- data/examples/legacy/texturesurf.rb +128 -0
- data/examples/legacy/varray.rb +167 -0
- data/examples/legacy/wrap.rb +158 -0
- data/examples/nehe_lesson02.rb +117 -0
- data/examples/nehe_lesson03.rb +122 -0
- data/examples/nehe_lesson04.rb +133 -0
- data/examples/nehe_lesson05.rb +186 -0
- data/examples/plane.rb +1 -1
- data/examples/smooth.rb +4 -2
- data/examples/test.rb +3 -2
- data/ext/common/{rbogl.c → common.h} +99 -32
- data/ext/common/gl-enums.h +39 -1
- data/ext/gl/gl-1.0-1.1.c +350 -305
- data/ext/gl/gl-1.2.c +933 -38
- data/ext/gl/gl-1.3.c +725 -0
- data/ext/gl/gl-1.4.c +647 -0
- data/ext/gl/gl-1.5.c +362 -0
- data/ext/gl/gl-2.0.c +1632 -0
- data/ext/gl/gl-2.1.c +154 -0
- data/ext/gl/gl-enums.c +1 -2
- data/ext/gl/gl.c +58 -2
- data/ext/gl/mkrf_conf.rb +4 -1
- data/ext/glu/glu.c +5 -4
- data/ext/glu/mkrf_conf.rb +4 -1
- data/ext/glut/glut.c +7 -1
- data/ext/glut/mkrf_conf.rb +5 -0
- data/lib/gl_prev.rb +4 -3
- data/lib/glu_prev.rb +4 -3
- data/lib/glut_prev.rb +3 -3
- data/{examples/all_tests.rb → lib/opengl.rb} +9 -12
- data/test/README +5 -18
- data/test/tc_common.rb +79 -0
- data/test/tc_func_10_11.rb +1255 -0
- data/test/tc_func_12.rb +186 -0
- data/test/tc_func_13.rb +203 -0
- data/test/tc_func_14.rb +197 -0
- data/test/tc_func_15.rb +82 -0
- data/test/tc_func_20.rb +320 -0
- data/test/tc_func_21.rb +67 -0
- data/test/tc_include_gl.rb +1 -1
- data/test/{tc_opengl_namespace.rb → tc_misc.rb} +20 -20
- data/test/tc_require_gl.rb +1 -1
- metadata +99 -27
- data/ext/common/Rakefile +0 -39
- data/ext/common/rbogl.h +0 -52
- data/test/runtests.sh +0 -7
- data/test/tc_gl_vertex.rb +0 -180
@@ -0,0 +1,153 @@
|
|
1
|
+
#!/usr/bin/env ruby -rubygems
|
2
|
+
#/*
|
3
|
+
# * Copyright (c) 1993-1997, Silicon Graphics, Inc.
|
4
|
+
# * ALL RIGHTS RESERVED
|
5
|
+
# * Permission to use, copy, modify, and distribute this software for
|
6
|
+
# * any purpose and without fee is hereby granted, provided that the above
|
7
|
+
# * copyright notice appear in all copies and that both the copyright notice
|
8
|
+
# * and this permission notice appear in supporting documentation, and that
|
9
|
+
# * the name of Silicon Graphics, Inc. not be used in advertising
|
10
|
+
# * or publicity pertaining to distribution of the software without specific,
|
11
|
+
# * written prior permission.
|
12
|
+
# *
|
13
|
+
# * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
14
|
+
# * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
15
|
+
# * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
16
|
+
# * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
17
|
+
# * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
18
|
+
# * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
19
|
+
# * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
20
|
+
# * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
21
|
+
# * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
22
|
+
# * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
23
|
+
# * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
24
|
+
# * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
25
|
+
# *
|
26
|
+
# * US Government Users Restricted Rights
|
27
|
+
# * Use, duplication, or disclosure by the Government is subject to
|
28
|
+
# * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
29
|
+
# * (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
30
|
+
# * clause at DFARS 252.227-7013 and/or in similar or successor
|
31
|
+
# * clauses in the FAR or the DOD or NASA FAR Supplement.
|
32
|
+
# * Unpublished-- rights reserved under the copyright laws of the
|
33
|
+
# * United States. Contractor/manufacturer is Silicon Graphics,
|
34
|
+
# * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
35
|
+
# *
|
36
|
+
# * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
|
37
|
+
# */
|
38
|
+
#
|
39
|
+
#/*
|
40
|
+
# * aapoly.c
|
41
|
+
# * This program draws filled polygons with antialiased
|
42
|
+
# * edges. The special GL_SRC_ALPHA_SATURATE blending
|
43
|
+
# * function is used.
|
44
|
+
# * Pressing the 't' key turns the antialiasing on and off.
|
45
|
+
# */
|
46
|
+
|
47
|
+
require "gl_prev"
|
48
|
+
require "glu_prev"
|
49
|
+
require "glut_prev"
|
50
|
+
|
51
|
+
$polySmooth = true
|
52
|
+
|
53
|
+
def init
|
54
|
+
GL::CullFace(GL::BACK);
|
55
|
+
GL::Enable(GL::CULL_FACE);
|
56
|
+
GL::BlendFunc(GL::SRC_ALPHA_SATURATE, GL::ONE);
|
57
|
+
GL::ClearColor(0.0, 0.0, 0.0, 0.0);
|
58
|
+
end
|
59
|
+
|
60
|
+
NFACE=6
|
61
|
+
NVERT=8
|
62
|
+
$indices = [
|
63
|
+
[4, 5, 6, 7], [2, 3, 7, 6], [0, 4, 7, 3],
|
64
|
+
[0, 1, 5, 4], [1, 5, 6, 2], [0, 3, 2, 1]
|
65
|
+
]
|
66
|
+
|
67
|
+
def drawCube(x0, x1, y0, y1, z0, z1)
|
68
|
+
v = [[],[],[],[],[],[],[],[]]
|
69
|
+
c = [
|
70
|
+
[0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 1.0],
|
71
|
+
[0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 0.0, 1.0],
|
72
|
+
[0.0, 0.0, 1.0, 1.0], [1.0, 0.0, 1.0, 1.0],
|
73
|
+
[0.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0]
|
74
|
+
];
|
75
|
+
|
76
|
+
#/* indices of front, top, left, bottom, right, back faces */
|
77
|
+
|
78
|
+
v[0][0] = v[3][0] = v[4][0] = v[7][0] = x0;
|
79
|
+
v[1][0] = v[2][0] = v[5][0] = v[6][0] = x1;
|
80
|
+
v[0][1] = v[1][1] = v[4][1] = v[5][1] = y0;
|
81
|
+
v[2][1] = v[3][1] = v[6][1] = v[7][1] = y1;
|
82
|
+
v[0][2] = v[1][2] = v[2][2] = v[3][2] = z0;
|
83
|
+
v[4][2] = v[5][2] = v[6][2] = v[7][2] = z1;
|
84
|
+
|
85
|
+
GL::EnableClientState(GL::VERTEX_ARRAY);
|
86
|
+
GL::EnableClientState(GL::COLOR_ARRAY);
|
87
|
+
GL::VertexPointer(3, GL::FLOAT, 0, v.flatten!.pack("f*"));
|
88
|
+
GL::ColorPointer(4, GL::FLOAT, 0, c.flatten!.pack("f*"));
|
89
|
+
GL::DrawElements(GL::QUADS, NFACE*4, GL::UNSIGNED_BYTE, $indices.flatten.pack("C*"));
|
90
|
+
GL::DisableClientState(GL::VERTEX_ARRAY);
|
91
|
+
GL::DisableClientState(GL::COLOR_ARRAY);
|
92
|
+
end
|
93
|
+
|
94
|
+
#/* Note: polygons must be drawn from front to back
|
95
|
+
# * for proper blending.
|
96
|
+
# */
|
97
|
+
display = proc {
|
98
|
+
if ($polySmooth)
|
99
|
+
GL::Clear(GL::COLOR_BUFFER_BIT);
|
100
|
+
GL::Enable(GL::BLEND);
|
101
|
+
GL::Enable(GL::POLYGON_SMOOTH);
|
102
|
+
GL::Disable(GL::DEPTH_TEST);
|
103
|
+
else
|
104
|
+
GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
105
|
+
GL::Disable(GL::BLEND);
|
106
|
+
GL::Disable(GL::POLYGON_SMOOTH);
|
107
|
+
GL::Enable(GL::DEPTH_TEST);
|
108
|
+
end
|
109
|
+
|
110
|
+
GL::PushMatrix();
|
111
|
+
GL::Translate(0.0, 0.0, -8.0);
|
112
|
+
GL::Rotate(30.0, 1.0, 0.0, 0.0);
|
113
|
+
GL::Rotate(60.0, 0.0, 1.0, 0.0);
|
114
|
+
drawCube(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);
|
115
|
+
GL::PopMatrix();
|
116
|
+
|
117
|
+
GL::Flush();
|
118
|
+
}
|
119
|
+
|
120
|
+
reshape = proc {|w, h|
|
121
|
+
GL::Viewport(0, 0, w, h);
|
122
|
+
GL::MatrixMode(GL::PROJECTION);
|
123
|
+
GL::LoadIdentity();
|
124
|
+
GLU::Perspective(30.0, w.to_f/ h.to_f, 1.0, 20.0);
|
125
|
+
GL::MatrixMode(GL::MODELVIEW);
|
126
|
+
GL::LoadIdentity();
|
127
|
+
}
|
128
|
+
|
129
|
+
# /* ARGSUSED1 */
|
130
|
+
keyboard = proc {|key, x, y|
|
131
|
+
case (key)
|
132
|
+
when ?t ,?T
|
133
|
+
$polySmooth = !$polySmooth;
|
134
|
+
GLUT::PostRedisplay();
|
135
|
+
when 27
|
136
|
+
exit(0); #/* Escape key */
|
137
|
+
end
|
138
|
+
}
|
139
|
+
|
140
|
+
#/* Main Loop
|
141
|
+
# */
|
142
|
+
#int main(int argc, char** argv)
|
143
|
+
#{
|
144
|
+
GLUT.Init
|
145
|
+
GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::ALPHA | GLUT::DEPTH);
|
146
|
+
GLUT.InitWindowSize(200, 200);
|
147
|
+
GLUT.CreateWindow($0)
|
148
|
+
init();
|
149
|
+
GLUT.ReshapeFunc(reshape);
|
150
|
+
GLUT.KeyboardFunc(keyboard);
|
151
|
+
GLUT.DisplayFunc(display);
|
152
|
+
GLUT.MainLoop();
|
153
|
+
|
@@ -0,0 +1,139 @@
|
|
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
|
+
# * aargb.c
|
40
|
+
# * This program draws shows how to draw anti-aliased lines. It draws
|
41
|
+
# * two diagonal lines to form an X; when 'r' is typed in the window,
|
42
|
+
# * the lines are rotated in opposite directions.
|
43
|
+
# */
|
44
|
+
|
45
|
+
require "gl_prev"
|
46
|
+
require "glu_prev"
|
47
|
+
require "glut_prev"
|
48
|
+
require "mathn"
|
49
|
+
|
50
|
+
$rotAngle = 0.0;
|
51
|
+
|
52
|
+
#/* Initialize antialiasing for RGBA mode, including alpha
|
53
|
+
# * blending, hint, and line width. Print out implementation
|
54
|
+
# * specific info on line width granularity and width.
|
55
|
+
# */
|
56
|
+
def init
|
57
|
+
# GLfloat values[2];
|
58
|
+
# glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values);
|
59
|
+
# printf ("GL_LINE_WIDTH_GRANULARITY value is %3.1f\n", values[0]);
|
60
|
+
|
61
|
+
# glGetFloatv (GL_LINE_WIDTH_RANGE, values);
|
62
|
+
# printf ("GL_LINE_WIDTH_RANGE values are %3.1f %3.1f\n",
|
63
|
+
# values[0], values[1]);
|
64
|
+
|
65
|
+
GL.Enable(GL::LINE_SMOOTH);
|
66
|
+
GL.Enable(GL::BLEND);
|
67
|
+
GL.BlendFunc(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA);
|
68
|
+
GL.Hint(GL::LINE_SMOOTH_HINT, GL::DONT_CARE);
|
69
|
+
GL.LineWidth(1.5);
|
70
|
+
|
71
|
+
GL.ClearColor(0.0, 0.0, 0.0, 0.0);
|
72
|
+
end
|
73
|
+
|
74
|
+
#/* Draw 2 diagonal lines to form an X
|
75
|
+
# */
|
76
|
+
display = Proc.new {
|
77
|
+
GL.Clear(GL::COLOR_BUFFER_BIT);
|
78
|
+
|
79
|
+
GL.Color(0.0, 1.0, 0.0);
|
80
|
+
GL.PushMatrix();
|
81
|
+
GL.Rotate(-$rotAngle, 0.0, 0.0, 0.1);
|
82
|
+
GL.Begin(GL::LINES);
|
83
|
+
GL.Vertex(-0.5, 0.5);
|
84
|
+
GL.Vertex(0.5, -0.5);
|
85
|
+
GL.End();
|
86
|
+
GL.PopMatrix();
|
87
|
+
|
88
|
+
GL.Color(0.0, 0.0, 1.0);
|
89
|
+
GL.PushMatrix();
|
90
|
+
GL.Rotate($rotAngle, 0.0, 0.0, 0.1);
|
91
|
+
GL.Begin(GL::LINES);
|
92
|
+
GL.Vertex(0.5, 0.5);
|
93
|
+
GL.Vertex(-0.5, -0.5);
|
94
|
+
GL.End();
|
95
|
+
GL.PopMatrix();
|
96
|
+
|
97
|
+
GL.Flush();
|
98
|
+
}
|
99
|
+
|
100
|
+
reshape = Proc.new {|w, h|
|
101
|
+
GL.Viewport(0, 0, w, h);
|
102
|
+
GL.MatrixMode(GL::PROJECTION);
|
103
|
+
GL.LoadIdentity();
|
104
|
+
if (w <= h)
|
105
|
+
GLU.Ortho2D(-1.0, 1.0, -1.0*h/w, 1.0*h/w);
|
106
|
+
else
|
107
|
+
GLU.Ortho2D(-1.0*w/h, 1.0*w/h, -1.0, 1.0);
|
108
|
+
end
|
109
|
+
GL.MatrixMode(GL::MODELVIEW);
|
110
|
+
GL.LoadIdentity();
|
111
|
+
}
|
112
|
+
|
113
|
+
# /* ARGSUSED1 */
|
114
|
+
keyboard = Proc.new {|key, x, y|
|
115
|
+
case (key)
|
116
|
+
when 'r'[0],'R'[0]
|
117
|
+
$rotAngle = $rotAngle + 20.0;
|
118
|
+
$rotAngle = 0.0 if ($rotAngle >= 360.0)
|
119
|
+
GLUT.PostRedisplay();
|
120
|
+
when 27 #/* Escape Key */
|
121
|
+
exit(0);
|
122
|
+
end
|
123
|
+
}
|
124
|
+
|
125
|
+
#/* Main Loop
|
126
|
+
# * Open window with initial window size, title bar,
|
127
|
+
# * RGBA display mode, and handle input events.
|
128
|
+
# */
|
129
|
+
#int main(int argc, char** argv)
|
130
|
+
#{
|
131
|
+
GLUT.Init
|
132
|
+
GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
|
133
|
+
GLUT.InitWindowSize(200, 200);
|
134
|
+
GLUT.CreateWindow($0);
|
135
|
+
init();
|
136
|
+
GLUT.ReshapeFunc(reshape);
|
137
|
+
GLUT.KeyboardFunc(keyboard);
|
138
|
+
GLUT.DisplayFunc(display);
|
139
|
+
GLUT.MainLoop();
|
@@ -0,0 +1,159 @@
|
|
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
|
+
#/* accanti.c
|
41
|
+
# */
|
42
|
+
require "gl_prev"
|
43
|
+
require "glu_prev"
|
44
|
+
require "glut_prev"
|
45
|
+
|
46
|
+
$LOAD_PATH.push(File.dirname($0)) # Find jitter in script directory
|
47
|
+
|
48
|
+
#/* Initialize lighting and other values.
|
49
|
+
# */
|
50
|
+
def myinit
|
51
|
+
mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ];
|
52
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];
|
53
|
+
light_position = [ 0.0, 0.0, 10.0, 1.0 ];
|
54
|
+
lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ];
|
55
|
+
|
56
|
+
GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient);
|
57
|
+
GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
|
58
|
+
GL::Material(GL::FRONT, GL::SHININESS, 50.0);
|
59
|
+
GL::Light(GL::LIGHT0, GL::POSITION, light_position);
|
60
|
+
GL::LightModel(GL::LIGHT_MODEL_AMBIENT, lm_ambient);
|
61
|
+
|
62
|
+
GL::Enable(GL::LIGHTING);
|
63
|
+
GL::Enable(GL::LIGHT0);
|
64
|
+
GL::DepthFunc(GL::LESS);
|
65
|
+
GL::Enable(GL::DEPTH_TEST);
|
66
|
+
GL::ShadeModel(GL::FLAT);
|
67
|
+
|
68
|
+
GL::ClearColor(0.0, 0.0, 0.0, 0.0);
|
69
|
+
GL::ClearAccum(0.0, 0.0, 0.0, 0.0);
|
70
|
+
end
|
71
|
+
|
72
|
+
def displayObjects
|
73
|
+
torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ];
|
74
|
+
cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ];
|
75
|
+
sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ];
|
76
|
+
octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ];
|
77
|
+
|
78
|
+
GL::PushMatrix();
|
79
|
+
GL::Rotate(30.0, 1.0, 0.0, 0.0);
|
80
|
+
|
81
|
+
GL::PushMatrix();
|
82
|
+
GL::Translate(-0.80, 0.35, 0.0);
|
83
|
+
GL::Rotate(100.0, 1.0, 0.0, 0.0);
|
84
|
+
GL::Material(GL::FRONT, GL::DIFFUSE, torus_diffuse);
|
85
|
+
GLUT::SolidTorus(0.275, 0.85, 16, 16);
|
86
|
+
GL::PopMatrix();
|
87
|
+
|
88
|
+
GL::PushMatrix();
|
89
|
+
GL::Translate(-0.75, -0.50, 0.0);
|
90
|
+
GL::Rotate(45.0, 0.0, 0.0, 1.0);
|
91
|
+
GL::Rotate(45.0, 1.0, 0.0, 0.0);
|
92
|
+
GL::Material(GL::FRONT, GL::DIFFUSE, cube_diffuse);
|
93
|
+
GLUT::SolidCube(1.5);
|
94
|
+
GL::PopMatrix();
|
95
|
+
|
96
|
+
GL::PushMatrix();
|
97
|
+
GL::Translate(0.75, 0.60, 0.0);
|
98
|
+
GL::Rotate(30.0, 1.0, 0.0, 0.0);
|
99
|
+
GL::Material(GL::FRONT, GL::DIFFUSE, sphere_diffuse);
|
100
|
+
GLUT::SolidSphere(1.0, 16, 16);
|
101
|
+
GL::PopMatrix();
|
102
|
+
|
103
|
+
GL::PushMatrix();
|
104
|
+
GL::Translate(0.70, -0.90, 0.25);
|
105
|
+
GL::Material(GL::FRONT, GL::DIFFUSE, octa_diffuse);
|
106
|
+
GLUT::SolidOctahedron();
|
107
|
+
GL::PopMatrix();
|
108
|
+
|
109
|
+
GL::PopMatrix();
|
110
|
+
end
|
111
|
+
|
112
|
+
ACSIZE=8
|
113
|
+
|
114
|
+
display = proc {
|
115
|
+
viewport = GL::GetDoublev(GL::VIEWPORT);
|
116
|
+
|
117
|
+
GL::Clear(GL::ACCUM_BUFFER_BIT);
|
118
|
+
for jitter in 0...ACSIZE
|
119
|
+
GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
120
|
+
GL::PushMatrix();
|
121
|
+
#/* Note that 4.5 is the distance in world space between
|
122
|
+
# * left and right and bottom and top.
|
123
|
+
# * This formula converts fractional pixel movement to
|
124
|
+
# * world coordinates.
|
125
|
+
# */
|
126
|
+
GL::Translate($j8[jitter][0]*4.5/viewport[2],
|
127
|
+
$j8[jitter][1]*4.5/viewport[3], 0.0);
|
128
|
+
displayObjects();
|
129
|
+
GL::PopMatrix();
|
130
|
+
GL::Accum(GL::ACCUM, 1.0/ACSIZE);
|
131
|
+
end
|
132
|
+
GL::Accum(GL::RETURN, 1.0);
|
133
|
+
GL::Flush();
|
134
|
+
}
|
135
|
+
|
136
|
+
myReshape = proc {|w, h|
|
137
|
+
GL::Viewport(0, 0, w, h);
|
138
|
+
GL::MatrixMode(GL::PROJECTION);
|
139
|
+
GL::LoadIdentity();
|
140
|
+
if (w <= h)
|
141
|
+
GL::Ortho(-2.25, 2.25, -2.25*h/w, 2.25*h/w, -10.0, 10.0);
|
142
|
+
else
|
143
|
+
GL::Ortho(-2.25*w/h, 2.25*w/h, -2.25, 2.25, -10.0, 10.0);
|
144
|
+
end
|
145
|
+
GL::MatrixMode(GL::MODELVIEW);
|
146
|
+
}
|
147
|
+
|
148
|
+
# /* Main Loop
|
149
|
+
# * Open window with initial window size, title bar,
|
150
|
+
# * RGBA display mode, and handle input events.
|
151
|
+
# */
|
152
|
+
GLUT.Init
|
153
|
+
GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::ACCUM | GLUT::DEPTH);
|
154
|
+
GLUT::InitWindowSize(250, 250);
|
155
|
+
GLUT::CreateWindow($0)
|
156
|
+
myinit();
|
157
|
+
GLUT::ReshapeFunc(myReshape);
|
158
|
+
GLUT::DisplayFunc(display);
|
159
|
+
GLUT::MainLoop();
|