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/smooth.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby -rubygems
|
2
|
-
require "gl_prev"
|
3
|
-
require "glut_prev"
|
4
|
-
|
5
|
-
STDOUT.sync=TRUE
|
6
|
-
disp = Proc.new {
|
7
|
-
GL.Clear(GL::COLOR_BUFFER_BIT)
|
8
|
-
GL.Begin(GL::TRIANGLES)
|
9
|
-
GL.Color(0.0, 0.0, 1.0)
|
10
|
-
GL.Vertex(0, 0)
|
11
|
-
GL.Color(0.0, 1.0, 0.0)
|
12
|
-
GL.Vertex(200, 200)
|
13
|
-
GL.Color(1.0, 0.0, 0.0)
|
14
|
-
GL.Vertex(20, 200)
|
15
|
-
GL.End
|
16
|
-
GL.Flush
|
17
|
-
}
|
18
|
-
|
19
|
-
reshape = Proc.new {|w, h|
|
20
|
-
GL.Viewport(0, 0, w, h)
|
21
|
-
GL.MatrixMode(GL::PROJECTION)
|
22
|
-
GL.LoadIdentity
|
23
|
-
GL.Ortho(0, w, 0, h, -1, 1)
|
24
|
-
GL.Scale(1, -1, 1)
|
25
|
-
GL.Translate(0, -h, 0)
|
26
|
-
}
|
27
|
-
|
28
|
-
# Keyboard handler to exit when ESC is typed
|
29
|
-
keyboard = lambda do |key, x, y|
|
30
|
-
case(key)
|
31
|
-
when 27
|
32
|
-
exit(0)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
GLUT.Init
|
37
|
-
a = GLUT.CreateWindow("single triangle");
|
38
|
-
GLUT.DisplayFunc(disp);
|
39
|
-
GLUT.ReshapeFunc(reshape);
|
40
|
-
GLUT.KeyboardFunc( keyboard )
|
41
|
-
GLUT.MainLoop;
|
data/examples/legacy/stencil.rb
DELETED
@@ -1,154 +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
|
-
# stencil.c
|
41
|
-
# This program draws two rotated tori in a window.
|
42
|
-
# A diamond in the center of the window masks out part
|
43
|
-
# of the scene. Within this mask, a different model
|
44
|
-
# (a sphere) is drawn in a different color.
|
45
|
-
#/
|
46
|
-
require "gl_prev"
|
47
|
-
require "glu_prev"
|
48
|
-
require "glut_prev"
|
49
|
-
require "rational"
|
50
|
-
|
51
|
-
YELLOWMAT=1
|
52
|
-
BLUEMAT=2
|
53
|
-
|
54
|
-
def myinit
|
55
|
-
yellow_diffuse = [ 0.7, 0.7, 0.0, 1.0 ];
|
56
|
-
yellow_specular = [ 1.0, 1.0, 1.0, 1.0 ];
|
57
|
-
|
58
|
-
blue_diffuse = [ 0.1, 0.1, 0.7, 1.0 ];
|
59
|
-
blue_specular = [ 0.1, 1.0, 1.0, 1.0 ];
|
60
|
-
|
61
|
-
position_one = [ 1.0, 1.0, 1.0, 0.0 ];
|
62
|
-
|
63
|
-
GL.NewList(YELLOWMAT, GL::COMPILE);
|
64
|
-
GL.Material(GL::FRONT, GL::DIFFUSE, yellow_diffuse);
|
65
|
-
GL.Material(GL::FRONT, GL::SPECULAR, yellow_specular);
|
66
|
-
GL.Material(GL::FRONT, GL::SHININESS, 64.0);
|
67
|
-
GL.EndList();
|
68
|
-
|
69
|
-
GL.NewList(BLUEMAT, GL::COMPILE);
|
70
|
-
GL.Material(GL::FRONT, GL::DIFFUSE, blue_diffuse);
|
71
|
-
GL.Material(GL::FRONT, GL::SPECULAR, blue_specular);
|
72
|
-
GL.Material(GL::FRONT, GL::SHININESS, 45.0);
|
73
|
-
GL.EndList();
|
74
|
-
|
75
|
-
GL.Light(GL::LIGHT0, GL::POSITION, position_one);
|
76
|
-
|
77
|
-
GL.Enable(GL::LIGHT0);
|
78
|
-
GL.Enable(GL::LIGHTING);
|
79
|
-
GL.DepthFunc(GL::LESS);
|
80
|
-
GL.Enable(GL::DEPTH_TEST);
|
81
|
-
|
82
|
-
GL.ClearStencil(0x0);
|
83
|
-
GL.Enable(GL::STENCIL_TEST);
|
84
|
-
end
|
85
|
-
|
86
|
-
# Draw a sphere in a diamond-shaped section in the
|
87
|
-
# middle of a window with 2 tori.
|
88
|
-
#/
|
89
|
-
display = Proc.new {
|
90
|
-
GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
91
|
-
|
92
|
-
# draw blue sphere where the stencil is 1 */
|
93
|
-
GL.StencilFunc(GL::EQUAL, 0x1, 0x1);
|
94
|
-
GL.CallList(BLUEMAT);
|
95
|
-
GLUT.SolidSphere(0.5, 15, 15);
|
96
|
-
|
97
|
-
# draw the tori where the stencil is not 1 */
|
98
|
-
GL.StencilFunc(GL::NOTEQUAL, 0x1, 0x1);
|
99
|
-
GL.StencilOp(GL::KEEP, GL::KEEP, GL::KEEP);
|
100
|
-
GL.PushMatrix();
|
101
|
-
GL.Rotate(45.0, 0.0, 0.0, 1.0);
|
102
|
-
GL.Rotate(45.0, 0.0, 1.0, 0.0);
|
103
|
-
GL.CallList(YELLOWMAT);
|
104
|
-
GLUT.SolidTorus(0.275, 0.85, 15, 15);
|
105
|
-
GL.PushMatrix();
|
106
|
-
GL.Rotate(90.0, 1.0, 0.0, 0.0);
|
107
|
-
GLUT.SolidTorus(0.275, 0.85, 15, 15);
|
108
|
-
GL.PopMatrix();
|
109
|
-
GL.PopMatrix();
|
110
|
-
}
|
111
|
-
|
112
|
-
# Whenever the window is reshaped, redefine the
|
113
|
-
# coordinate system and redraw the stencil area.
|
114
|
-
#/
|
115
|
-
myReshape = Proc.new {|w, h|
|
116
|
-
GL.Viewport(0, 0, w, h);
|
117
|
-
|
118
|
-
GL.Clear(GL::STENCIL_BUFFER_BIT);
|
119
|
-
# create a diamond shaped stencil area */
|
120
|
-
GL.MatrixMode(GL::PROJECTION);
|
121
|
-
GL.LoadIdentity();
|
122
|
-
GL.Ortho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0);
|
123
|
-
GL.MatrixMode(GL::MODELVIEW);
|
124
|
-
GL.LoadIdentity();
|
125
|
-
|
126
|
-
GL.StencilFunc(GL::ALWAYS, 0x1, 0x1);
|
127
|
-
GL.StencilOp(GL::REPLACE, GL::REPLACE, GL::REPLACE);
|
128
|
-
GL.Begin(GL::QUADS);
|
129
|
-
GL.Vertex(-1.0, 0.0, 0.0);
|
130
|
-
GL.Vertex(0.0, 1.0, 0.0);
|
131
|
-
GL.Vertex(1.0, 0.0, 0.0);
|
132
|
-
GL.Vertex(0.0, -1.0, 0.0);
|
133
|
-
GL.End();
|
134
|
-
|
135
|
-
GL.MatrixMode(GL::PROJECTION);
|
136
|
-
GL.LoadIdentity();
|
137
|
-
GLU.Perspective(45.0, w.to_f/h.to_f, 3.0, 7.0);
|
138
|
-
GL.MatrixMode(GL::MODELVIEW);
|
139
|
-
GL.LoadIdentity();
|
140
|
-
GL.Translate(0.0, 0.0, -5.0);
|
141
|
-
}
|
142
|
-
|
143
|
-
# Main Loop
|
144
|
-
# Open window with initial window size, title bar,
|
145
|
-
# RGBA display mode, and handle input events.
|
146
|
-
#/
|
147
|
-
GLUT.Init()
|
148
|
-
GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH | GLUT::STENCIL);
|
149
|
-
GLUT.InitWindowSize(400, 400);
|
150
|
-
GLUT.CreateWindow($0);
|
151
|
-
myinit
|
152
|
-
GLUT.ReshapeFunc(myReshape);
|
153
|
-
GLUT.DisplayFunc(display);
|
154
|
-
GLUT.MainLoop();
|
data/examples/legacy/stroke.rb
DELETED
@@ -1,170 +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
|
-
# * stroke.c
|
42
|
-
# * This program demonstrates some characters of a
|
43
|
-
# * stroke (vector) font. The characters are represented
|
44
|
-
# * by display lists, which are given numbers which
|
45
|
-
# * correspond to the ASCII values of the characters.
|
46
|
-
# * Use of glCallLists() is demonstrated.
|
47
|
-
# */
|
48
|
-
|
49
|
-
require "gl_prev"
|
50
|
-
require "glu_prev"
|
51
|
-
require "glut_prev"
|
52
|
-
require "mathn"
|
53
|
-
|
54
|
-
PT=1
|
55
|
-
STROKE=2
|
56
|
-
END_=3
|
57
|
-
|
58
|
-
Adata = [
|
59
|
-
[[0, 0], PT], [[0, 9], PT], [[1, 10], PT], [[4, 10], PT],
|
60
|
-
[[5, 9], PT], [[5, 0], STROKE], [[0, 5], PT], [[5, 5], END_]
|
61
|
-
];
|
62
|
-
|
63
|
-
Edata = [
|
64
|
-
[[5, 0], PT], [[0, 0], PT], [[0, 10], PT], [[5, 10], STROKE],
|
65
|
-
[[0, 5], PT], [[4, 5], END_]
|
66
|
-
];
|
67
|
-
|
68
|
-
Pdata = [
|
69
|
-
[[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
|
70
|
-
[[4, 5], PT], [[0, 5], END_]
|
71
|
-
];
|
72
|
-
|
73
|
-
Rdata = [
|
74
|
-
[[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
|
75
|
-
[[4, 5], PT], [[0, 5], STROKE], [[3, 5], PT], [[5, 0], END_]
|
76
|
-
];
|
77
|
-
|
78
|
-
Sdata = [
|
79
|
-
[[0, 1], PT], [[1, 0], PT], [[4, 0], PT], [[5, 1], PT], [[5, 4], PT],
|
80
|
-
[[4, 5], PT], [[1, 5], PT], [[0, 6], PT], [[0, 9], PT], [[1, 10], PT],
|
81
|
-
[[4, 10], PT], [[5, 9], END_]
|
82
|
-
];
|
83
|
-
|
84
|
-
#/* drawLetter() interprets the instructions from the array
|
85
|
-
# * for that letter and renders the letter with line segments.
|
86
|
-
# */
|
87
|
-
def drawLetter(l)
|
88
|
-
i = 0
|
89
|
-
GL.Begin(GL::LINE_STRIP);
|
90
|
-
while (1)
|
91
|
-
case (l[i][1])
|
92
|
-
when PT
|
93
|
-
GL.Vertex(l[i][0]);
|
94
|
-
when STROKE
|
95
|
-
GL.Vertex(l[i][0]);
|
96
|
-
GL.End();
|
97
|
-
GL.Begin(GL::LINE_STRIP);
|
98
|
-
when END_
|
99
|
-
GL.Vertex(l[i][0]);
|
100
|
-
GL.End();
|
101
|
-
GL.Translate(8.0, 0.0, 0.0);
|
102
|
-
return
|
103
|
-
end
|
104
|
-
i = i + 1
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# /* Create a display list for each of 6 characters */
|
109
|
-
def myinit
|
110
|
-
GL.ShadeModel (GL::FLAT);
|
111
|
-
|
112
|
-
base = GL.GenLists(128);
|
113
|
-
GL.ListBase(base);
|
114
|
-
GL.NewList(base+'A'[0], GL::COMPILE); drawLetter(Adata); GL.EndList();
|
115
|
-
GL.NewList(base+'E'[0], GL::COMPILE); drawLetter(Edata); GL.EndList();
|
116
|
-
GL.NewList(base+'P'[0], GL::COMPILE); drawLetter(Pdata); GL.EndList();
|
117
|
-
GL.NewList(base+'R'[0], GL::COMPILE); drawLetter(Rdata); GL.EndList();
|
118
|
-
GL.NewList(base+'S'[0], GL::COMPILE); drawLetter(Sdata); GL.EndList();
|
119
|
-
GL.NewList(base+' '[0], GL::COMPILE); GL.Translate(8.0, 0.0, 0.0); GL.EndList();
|
120
|
-
end
|
121
|
-
|
122
|
-
$test1 = "A SPARE SERAPE APPEARS AS";
|
123
|
-
$test2 = "APES PREPARE RARE PEPPERS";
|
124
|
-
|
125
|
-
def printStrokedString(s)
|
126
|
-
# GL.CallLists(s.size, GL::BYTE, s);
|
127
|
-
GL.CallLists( s);
|
128
|
-
end
|
129
|
-
|
130
|
-
display = Proc.new {
|
131
|
-
GL.Clear(GL::COLOR_BUFFER_BIT);
|
132
|
-
GL.Color(1.0, 1.0, 1.0);
|
133
|
-
GL.PushMatrix();
|
134
|
-
GL.Scale(2.0, 2.0, 2.0);
|
135
|
-
GL.Translate(10.0, 30.0, 0.0);
|
136
|
-
printStrokedString($test1);
|
137
|
-
GL.PopMatrix();
|
138
|
-
GL.PushMatrix();
|
139
|
-
GL.Scale(2.0, 2.0, 2.0);
|
140
|
-
GL.Translate(10.0, 13.0, 0.0);
|
141
|
-
printStrokedString($test2);
|
142
|
-
GL.PopMatrix();
|
143
|
-
GL.Flush();
|
144
|
-
}
|
145
|
-
|
146
|
-
reshape = Proc.new {|w, h|
|
147
|
-
GL.Viewport(0, 0, w, h);
|
148
|
-
GL.MatrixMode(GL::PROJECTION);
|
149
|
-
GL.LoadIdentity();
|
150
|
-
GL.Ortho(0.0, w, 0.0, h, -1.0, 1.0);
|
151
|
-
GL.MatrixMode(GL::MODELVIEW);
|
152
|
-
GL.LoadIdentity();
|
153
|
-
}
|
154
|
-
|
155
|
-
#/* Main Loop
|
156
|
-
# * Open window with initial window size, title bar,
|
157
|
-
# * RGBA display mode, and handle input events.
|
158
|
-
# */
|
159
|
-
#int main(int argc, char** argv)
|
160
|
-
#{
|
161
|
-
GLUT.Init
|
162
|
-
GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
|
163
|
-
GLUT.InitWindowSize(440, 120);
|
164
|
-
GLUT.CreateWindow($0);
|
165
|
-
myinit();
|
166
|
-
GLUT.DisplayFunc(display);
|
167
|
-
GLUT.ReshapeFunc(reshape);
|
168
|
-
GLUT.MainLoop();
|
169
|
-
# return 0; /* ANSI C requires main to return int. */
|
170
|
-
#}
|
data/examples/legacy/surface.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
#/* aux2glut conversion Copyright (c) Mark J. Kilgard, 1994, 1995 */
|
2
|
-
#
|
3
|
-
#/**
|
4
|
-
# * (c) Copyright 1993, Silicon Graphics, Inc.
|
5
|
-
# * ALL RIGHTS RESERVED
|
6
|
-
# * Permission to use, copy, modify, and distribute this software for
|
7
|
-
# * any purpose and without fee is hereby granted, provided that the above
|
8
|
-
# * copyright notice appear in all copies and that both the copyright notice
|
9
|
-
# * and this permission notice appear in supporting documentation, and that
|
10
|
-
# * the name of Silicon Graphics, Inc. not be used in advertising
|
11
|
-
# * or publicity pertaining to distribution of the software without specific,
|
12
|
-
# * written prior permission.
|
13
|
-
# *
|
14
|
-
# * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
15
|
-
# * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
16
|
-
# * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
17
|
-
# * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
18
|
-
# * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
19
|
-
# * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
20
|
-
# * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
21
|
-
# * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
22
|
-
# * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
23
|
-
# * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
24
|
-
# * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
25
|
-
# * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
26
|
-
# *
|
27
|
-
# * US Government Users Restricted Rights
|
28
|
-
# * Use, duplication, or disclosure by the Government is subject to
|
29
|
-
# * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
30
|
-
# * (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
31
|
-
# * clause at DFARS 252.227-7013 and/or in similar or successor
|
32
|
-
# * clauses in the FAR or the DOD or NASA FAR Supplement.
|
33
|
-
# * Unpublished-- rights reserved under the copyright laws of the
|
34
|
-
# * United States. Contractor/manufacturer is Silicon Graphics,
|
35
|
-
# * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
36
|
-
# *
|
37
|
-
# * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
38
|
-
# */
|
39
|
-
#/**
|
40
|
-
# * surface.c
|
41
|
-
# * This program draws a NURBS surface in the shape of a
|
42
|
-
# * symmetrical hill.
|
43
|
-
# */
|
44
|
-
|
45
|
-
require "gl_prev"
|
46
|
-
require "glu_prev"
|
47
|
-
require "glut_prev"
|
48
|
-
require "mathn"
|
49
|
-
|
50
|
-
$ctlpoints = [];
|
51
|
-
$showPoints = 0;
|
52
|
-
|
53
|
-
$theNurb = nil;
|
54
|
-
|
55
|
-
#/*
|
56
|
-
# * Initializes the control points of the surface to a small hill.
|
57
|
-
# * The control points range from -3 to +3 in x, y, and z
|
58
|
-
# */
|
59
|
-
def init_surface
|
60
|
-
for u in 0..3
|
61
|
-
for v in 0..3
|
62
|
-
$ctlpoints[u*4*3+v*3+0] = 2.0*(u - 1.5);
|
63
|
-
$ctlpoints[u*4*3+v*3+1] = 2.0*(v - 1.5);
|
64
|
-
|
65
|
-
if ( (u == 1 || u == 2) && (v == 1 || v == 2))
|
66
|
-
$ctlpoints[u*4*3+v*3+2] = 7.0;
|
67
|
-
else
|
68
|
-
$ctlpoints[u*4*3+v*3+2] = -3.0;
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
#/* Initialize material property and depth buffer.
|
75
|
-
# */
|
76
|
-
def myinit
|
77
|
-
mat_diffuse = [ 0.7, 0.7, 0.7, 1.0 ];
|
78
|
-
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];
|
79
|
-
mat_shininess = [ 100.0 ];
|
80
|
-
|
81
|
-
GL.ClearColor(0.0, 0.0, 0.0, 1.0);
|
82
|
-
GL.Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
|
83
|
-
GL.Material(GL::FRONT, GL::SPECULAR, mat_specular);
|
84
|
-
GL.Material(GL::FRONT, GL::SHININESS, mat_shininess);
|
85
|
-
|
86
|
-
GL.Enable(GL::LIGHTING);
|
87
|
-
GL.Enable(GL::LIGHT0);
|
88
|
-
GL.DepthFunc(GL::LESS);
|
89
|
-
GL.Enable(GL::DEPTH_TEST);
|
90
|
-
GL.Enable(GL::AUTO_NORMAL);
|
91
|
-
GL.Enable(GL::NORMALIZE);
|
92
|
-
|
93
|
-
init_surface();
|
94
|
-
|
95
|
-
$theNurb = GLU.NewNurbsRenderer();
|
96
|
-
GLU.NurbsProperty($theNurb, GLU::SAMPLING_TOLERANCE, 25.0);
|
97
|
-
GLU.NurbsProperty($theNurb, GLU::DISPLAY_MODE, GLU::FILL);
|
98
|
-
end
|
99
|
-
|
100
|
-
display = Proc.new {
|
101
|
-
knots = [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0];
|
102
|
-
|
103
|
-
GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
|
104
|
-
|
105
|
-
GL.PushMatrix();
|
106
|
-
GL.Rotate(330.0, 1.0,0.0,0.0);
|
107
|
-
GL.Scale(0.25, 0.25, 0.25);
|
108
|
-
|
109
|
-
GLU.BeginSurface($theNurb);
|
110
|
-
GLU.NurbsSurface($theNurb,
|
111
|
-
8, knots,
|
112
|
-
8, knots,
|
113
|
-
4 * 3,
|
114
|
-
3,
|
115
|
-
$ctlpoints,
|
116
|
-
4, 4,
|
117
|
-
GL::MAP2_VERTEX_3);
|
118
|
-
GLU.EndSurface($theNurb);
|
119
|
-
|
120
|
-
if($showPoints==1)
|
121
|
-
GL.PointSize(5.0);
|
122
|
-
GL.Disable(GL::LIGHTING);
|
123
|
-
GL.Color(1.0, 1.0, 0.0);
|
124
|
-
GL.Begin(GL::POINTS);
|
125
|
-
for i in 0..3
|
126
|
-
for j in 0..3
|
127
|
-
GL.Vertex($ctlpoints[i*4*3+j*3+0], $ctlpoints[i*4*3+j*3+1], $ctlpoints[i*4*3+j*3+2]);
|
128
|
-
end
|
129
|
-
end
|
130
|
-
GL.End();
|
131
|
-
GL.Enable(GL::LIGHTING);
|
132
|
-
end
|
133
|
-
|
134
|
-
GL.PopMatrix();
|
135
|
-
GL.Flush();
|
136
|
-
}
|
137
|
-
|
138
|
-
reshape = Proc.new {|w, h|
|
139
|
-
GL.Viewport(0, 0, w, h);
|
140
|
-
GL.MatrixMode(GL::PROJECTION);
|
141
|
-
GL.LoadIdentity();
|
142
|
-
GLU.Perspective(45.0, w/h, 3.0, 8.0);
|
143
|
-
|
144
|
-
GL.MatrixMode(GL::MODELVIEW);
|
145
|
-
GL.LoadIdentity();
|
146
|
-
GL.Translate(0.0, 0.0, -5.0);
|
147
|
-
}
|
148
|
-
|
149
|
-
menu = Proc.new {|value|
|
150
|
-
$showPoints = value;
|
151
|
-
GLUT.PostRedisplay();
|
152
|
-
}
|
153
|
-
|
154
|
-
#/* Main Loop */
|
155
|
-
#int
|
156
|
-
#main(int argc, char** argv)
|
157
|
-
#{
|
158
|
-
GLUT.Init
|
159
|
-
GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
|
160
|
-
GLUT.CreateWindow($0);
|
161
|
-
myinit();
|
162
|
-
GLUT.ReshapeFunc(reshape);
|
163
|
-
GLUT.DisplayFunc(display);
|
164
|
-
GLUT.CreateMenu(menu);
|
165
|
-
GLUT.AddMenuEntry("Show control points", 1);
|
166
|
-
GLUT.AddMenuEntry("Hide control points", 0);
|
167
|
-
GLUT.AttachMenu(GLUT::RIGHT_BUTTON);
|
168
|
-
GLUT.MainLoop();
|
169
|
-
# return 0; /* ANSI C requires main to return int. */
|
170
|
-
#}
|