ruby-opengl 0.60.0-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +18 -0
- data/README.txt +47 -0
- data/doc/build_install.txt +122 -0
- data/doc/history.txt +66 -0
- data/doc/requirements_and_design.txt +117 -0
- data/doc/roadmap.txt +28 -0
- data/doc/scientific_use.txt +35 -0
- data/doc/thanks.txt +29 -0
- data/doc/tutorial.txt +469 -0
- data/examples/NeHe/nehe_lesson02.rb +117 -0
- data/examples/NeHe/nehe_lesson03.rb +122 -0
- data/examples/NeHe/nehe_lesson04.rb +133 -0
- data/examples/NeHe/nehe_lesson05.rb +186 -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 +376 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +406 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +16 -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/RedBook/double.rb +105 -0
- data/examples/RedBook/drawf.rb +91 -0
- 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/RedBook/jitter.rb +207 -0
- 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/RedBook/model.rb +113 -0
- data/examples/RedBook/movelight.rb +132 -0
- data/examples/RedBook/pickdepth.rb +179 -0
- data/examples/RedBook/planet.rb +108 -0
- 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/OGLBench.rb +337 -0
- data/examples/misc/anisotropic.rb +194 -0
- data/examples/misc/fbo_test.rb +356 -0
- data/examples/misc/font-glut.rb +46 -0
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/plane.rb +161 -0
- data/examples/misc/readpixel.rb +65 -0
- data/examples/misc/sdltest.rb +34 -0
- data/examples/misc/trislam.rb +828 -0
- data/lib/gl.so +0 -0
- data/lib/glu.so +0 -0
- data/lib/glut.so +0 -0
- data/lib/opengl.rb +84 -0
- metadata +132 -0
@@ -0,0 +1,95 @@
|
|
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
|
+
# smooth.c
|
38
|
+
# This program demonstrates smooth shading.
|
39
|
+
# A smooth shaded polygon is drawn in a 2-D projection.
|
40
|
+
|
41
|
+
require 'opengl'
|
42
|
+
include Gl,Glu,Glut
|
43
|
+
|
44
|
+
def init
|
45
|
+
glClearColor(0,0,0,0)
|
46
|
+
glShadeModel(GL_SMOOTH)
|
47
|
+
end
|
48
|
+
|
49
|
+
def triangle
|
50
|
+
glBegin(GL_TRIANGLES)
|
51
|
+
glColor3f(1.0, 0.0, 0.0)
|
52
|
+
glVertex2f(5, 5)
|
53
|
+
glColor3f(0.0, 1.0, 0.0)
|
54
|
+
glVertex2f(25, 5)
|
55
|
+
glColor3f(0.0, 0.0, 1.0)
|
56
|
+
glVertex2f(5, 25)
|
57
|
+
glEnd()
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
display = Proc.new do
|
62
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
63
|
+
triangle
|
64
|
+
glutSwapBuffers()
|
65
|
+
end
|
66
|
+
|
67
|
+
reshape = Proc.new do |w, h|
|
68
|
+
glViewport(0, 0, w, h)
|
69
|
+
glMatrixMode(GL_PROJECTION)
|
70
|
+
glLoadIdentity
|
71
|
+
if w<=h
|
72
|
+
gluOrtho2D(0,30,0, 30 * h/w)
|
73
|
+
else
|
74
|
+
gluOrtho2D(0,30 * w/h, 0,30)
|
75
|
+
end
|
76
|
+
glMatrixMode(GL_MODELVIEW)
|
77
|
+
end
|
78
|
+
|
79
|
+
keyboard = lambda do |key, x, y|
|
80
|
+
case(key)
|
81
|
+
when ?\e
|
82
|
+
exit(0)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
glutInit()
|
87
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
88
|
+
glutInitWindowSize(500, 500)
|
89
|
+
glutInitWindowPosition(100, 100)
|
90
|
+
glutCreateWindow($0)
|
91
|
+
init()
|
92
|
+
glutDisplayFunc(display)
|
93
|
+
glutReshapeFunc(reshape)
|
94
|
+
glutKeyboardFunc(keyboard)
|
95
|
+
glutMainLoop()
|
@@ -0,0 +1,163 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) Mark J. Kilgard, 1994.
|
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
|
+
# stencil.c
|
40
|
+
# This program draws two rotated tori in a window.
|
41
|
+
# A diamond in the center of the window masks out part
|
42
|
+
# of the scene. Within this mask, a different model
|
43
|
+
# (a sphere) is drawn in a different color.
|
44
|
+
#
|
45
|
+
require 'opengl'
|
46
|
+
require 'rational'
|
47
|
+
include Gl,Glu,Glut
|
48
|
+
|
49
|
+
YELLOWMAT=1
|
50
|
+
BLUEMAT=2
|
51
|
+
|
52
|
+
def myinit
|
53
|
+
yellow_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
|
54
|
+
yellow_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
55
|
+
|
56
|
+
blue_diffuse = [ 0.1, 0.1, 0.7, 1.0 ]
|
57
|
+
blue_specular = [ 0.1, 1.0, 1.0, 1.0 ]
|
58
|
+
|
59
|
+
position_one = [ 1.0, 1.0, 1.0, 0.0 ]
|
60
|
+
|
61
|
+
glNewList(YELLOWMAT, GL_COMPILE)
|
62
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, yellow_diffuse)
|
63
|
+
glMaterial(GL_FRONT, GL_SPECULAR, yellow_specular)
|
64
|
+
glMaterial(GL_FRONT, GL_SHININESS, 64.0)
|
65
|
+
glEndList()
|
66
|
+
|
67
|
+
glNewList(BLUEMAT, GL_COMPILE)
|
68
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, blue_diffuse)
|
69
|
+
glMaterial(GL_FRONT, GL_SPECULAR, blue_specular)
|
70
|
+
glMaterial(GL_FRONT, GL_SHININESS, 45.0)
|
71
|
+
glEndList()
|
72
|
+
|
73
|
+
glLight(GL_LIGHT0, GL_POSITION, position_one)
|
74
|
+
|
75
|
+
glEnable(GL_LIGHT0)
|
76
|
+
glEnable(GL_LIGHTING)
|
77
|
+
glEnable(GL_DEPTH_TEST)
|
78
|
+
|
79
|
+
glClearStencil(0x0)
|
80
|
+
glEnable(GL_STENCIL_TEST)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Draw a sphere in a diamond-shaped section in the
|
84
|
+
# middle of a window with 2 tori.
|
85
|
+
display = Proc.new do
|
86
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
87
|
+
|
88
|
+
# draw blue sphere where the stencil is 1
|
89
|
+
glStencilFunc(GL_EQUAL, 0x1, 0x1)
|
90
|
+
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)
|
91
|
+
glCallList(BLUEMAT)
|
92
|
+
glutSolidSphere(0.5, 15, 15)
|
93
|
+
|
94
|
+
# draw the tori where the stencil is not 1
|
95
|
+
glStencilFunc(GL_NOTEQUAL, 0x1, 0x1)
|
96
|
+
glPushMatrix()
|
97
|
+
glRotate(45.0, 0.0, 0.0, 1.0)
|
98
|
+
glRotate(45.0, 0.0, 1.0, 0.0)
|
99
|
+
glCallList(YELLOWMAT)
|
100
|
+
glutSolidTorus(0.275, 0.85, 15, 15)
|
101
|
+
glPushMatrix()
|
102
|
+
glRotate(90.0, 1.0, 0.0, 0.0)
|
103
|
+
glutSolidTorus(0.275, 0.85, 15, 15)
|
104
|
+
glPopMatrix()
|
105
|
+
glPopMatrix()
|
106
|
+
|
107
|
+
glutSwapBuffers()
|
108
|
+
end
|
109
|
+
|
110
|
+
# Whenever the window is reshaped, redefine the
|
111
|
+
# coordinate system and redraw the stencil area.
|
112
|
+
myReshape = Proc.new do |w, h|
|
113
|
+
glViewport(0, 0, w, h)
|
114
|
+
|
115
|
+
# create a diamond shaped stencil area
|
116
|
+
glMatrixMode(GL_PROJECTION)
|
117
|
+
glLoadIdentity()
|
118
|
+
if w<=h
|
119
|
+
gluOrtho2D(-3.0, 3.0, -3.0*h/w, 3*h/w)
|
120
|
+
else
|
121
|
+
gluOrtho2D(-3.0*w/h, 3.0*w/h, -3.0, 3)
|
122
|
+
end
|
123
|
+
glMatrixMode(GL_MODELVIEW)
|
124
|
+
glLoadIdentity()
|
125
|
+
|
126
|
+
glClear(GL_STENCIL_BUFFER_BIT)
|
127
|
+
glStencilFunc(GL_ALWAYS, 0x1, 0x1)
|
128
|
+
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE)
|
129
|
+
glBegin(GL_QUADS)
|
130
|
+
glVertex2f(-1.0, 0.0)
|
131
|
+
glVertex2f(0.0, 1.0)
|
132
|
+
glVertex2f(1.0, 0.0)
|
133
|
+
glVertex2f(0.0, -1.0)
|
134
|
+
glEnd()
|
135
|
+
|
136
|
+
glMatrixMode(GL_PROJECTION)
|
137
|
+
glLoadIdentity()
|
138
|
+
GLU.Perspective(45.0, w.to_f/h.to_f, 3.0, 7.0)
|
139
|
+
glMatrixMode(GL_MODELVIEW)
|
140
|
+
glLoadIdentity()
|
141
|
+
glTranslate(0.0, 0.0, -5.0)
|
142
|
+
end
|
143
|
+
|
144
|
+
keyboard = Proc.new do |key, x, y|
|
145
|
+
case (key)
|
146
|
+
when ?\e
|
147
|
+
exit(0);
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Main Loop
|
152
|
+
# Open window with initial window size, title bar,
|
153
|
+
# RGB display mode, and handle input events.
|
154
|
+
glutInit()
|
155
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL)
|
156
|
+
glutInitWindowSize(500, 500)
|
157
|
+
glutInitWindowPosition(100, 100)
|
158
|
+
glutCreateWindow($0)
|
159
|
+
myinit
|
160
|
+
glutReshapeFunc(myReshape)
|
161
|
+
glutDisplayFunc(display)
|
162
|
+
glutKeyboardFunc(keyboard)
|
163
|
+
glutMainLoop()
|
@@ -0,0 +1,167 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) Mark J. Kilgard, 1994.
|
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
|
+
# stroke.c
|
40
|
+
# This program demonstrates some characters of a
|
41
|
+
# stroke (vector) font. The characters are represented
|
42
|
+
# by display lists, which are given numbers which
|
43
|
+
# correspond to the ASCII values of the characters.
|
44
|
+
# Use of glCallLists() is demonstrated.
|
45
|
+
require 'opengl'
|
46
|
+
require 'mathn'
|
47
|
+
include Gl,Glu,Glut
|
48
|
+
|
49
|
+
PT=1
|
50
|
+
STROKE=2
|
51
|
+
END_=3
|
52
|
+
|
53
|
+
Adata = [
|
54
|
+
[[0, 0], PT], [[0, 9], PT], [[1, 10], PT], [[4, 10], PT],
|
55
|
+
[[5, 9], PT], [[5, 0], STROKE], [[0, 5], PT], [[5, 5], END_]
|
56
|
+
]
|
57
|
+
|
58
|
+
Edata = [
|
59
|
+
[[5, 0], PT], [[0, 0], PT], [[0, 10], PT], [[5, 10], STROKE],
|
60
|
+
[[0, 5], PT], [[4, 5], END_]
|
61
|
+
]
|
62
|
+
|
63
|
+
Pdata = [
|
64
|
+
[[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
|
65
|
+
[[4, 5], PT], [[0, 5], END_]
|
66
|
+
]
|
67
|
+
|
68
|
+
Rdata = [
|
69
|
+
[[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
|
70
|
+
[[4, 5], PT], [[0, 5], STROKE], [[3, 5], PT], [[5, 0], END_]
|
71
|
+
]
|
72
|
+
|
73
|
+
Sdata = [
|
74
|
+
[[0, 1], PT], [[1, 0], PT], [[4, 0], PT], [[5, 1], PT], [[5, 4], PT],
|
75
|
+
[[4, 5], PT], [[1, 5], PT], [[0, 6], PT], [[0, 9], PT], [[1, 10], PT],
|
76
|
+
[[4, 10], PT], [[5, 9], END_]
|
77
|
+
]
|
78
|
+
|
79
|
+
# drawLetter() interprets the instructions from the array
|
80
|
+
# for that letter and renders the letter with line segments.
|
81
|
+
def drawLetter(l)
|
82
|
+
i = 0
|
83
|
+
glBegin(GL_LINE_STRIP)
|
84
|
+
while true
|
85
|
+
case (l[i][1])
|
86
|
+
when PT
|
87
|
+
glVertex(l[i][0])
|
88
|
+
when STROKE
|
89
|
+
glVertex(l[i][0])
|
90
|
+
glEnd()
|
91
|
+
glBegin(GL_LINE_STRIP)
|
92
|
+
when END_
|
93
|
+
glVertex(l[i][0])
|
94
|
+
glEnd()
|
95
|
+
glTranslate(8.0, 0.0, 0.0)
|
96
|
+
return
|
97
|
+
end
|
98
|
+
i += 1
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Create a display list for each of 6 characters
|
103
|
+
def myinit
|
104
|
+
glShadeModel(GL_FLAT)
|
105
|
+
|
106
|
+
base = glGenLists(128)
|
107
|
+
glListBase(base)
|
108
|
+
glNewList(base+'A'[0], GL_COMPILE); drawLetter(Adata); glEndList()
|
109
|
+
glNewList(base+'E'[0], GL_COMPILE); drawLetter(Edata); glEndList()
|
110
|
+
glNewList(base+'P'[0], GL_COMPILE); drawLetter(Pdata); glEndList()
|
111
|
+
glNewList(base+'R'[0], GL_COMPILE); drawLetter(Rdata); glEndList()
|
112
|
+
glNewList(base+'S'[0], GL_COMPILE); drawLetter(Sdata); glEndList()
|
113
|
+
glNewList(base+' '[0], GL_COMPILE); glTranslate(8.0, 0.0, 0.0); glEndList()
|
114
|
+
end
|
115
|
+
|
116
|
+
$test1 = "A SPARE SERAPE APPEARS AS"
|
117
|
+
$test2 = "APES PREPARE RARE PEPPERS"
|
118
|
+
|
119
|
+
def printStrokedString(s)
|
120
|
+
glCallLists(GL_BYTE,s)
|
121
|
+
end
|
122
|
+
|
123
|
+
display = Proc.new do
|
124
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
125
|
+
glColor(1.0, 1.0, 1.0)
|
126
|
+
glPushMatrix()
|
127
|
+
glScale(2.0, 2.0, 2.0)
|
128
|
+
glTranslate(10.0, 30.0, 0.0)
|
129
|
+
printStrokedString($test1)
|
130
|
+
glPopMatrix()
|
131
|
+
glPushMatrix()
|
132
|
+
glScale(2.0, 2.0, 2.0)
|
133
|
+
glTranslate(10.0, 13.0, 0.0)
|
134
|
+
printStrokedString($test2)
|
135
|
+
glPopMatrix()
|
136
|
+
glutSwapBuffers()
|
137
|
+
end
|
138
|
+
|
139
|
+
reshape = Proc.new do |w, h|
|
140
|
+
glViewport(0, 0, w, h)
|
141
|
+
glMatrixMode(GL_PROJECTION)
|
142
|
+
glLoadIdentity()
|
143
|
+
glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
|
144
|
+
glMatrixMode(GL_MODELVIEW)
|
145
|
+
glLoadIdentity()
|
146
|
+
end
|
147
|
+
|
148
|
+
keyboard = Proc.new do |key, x, y|
|
149
|
+
case (key)
|
150
|
+
when ?\e
|
151
|
+
exit(0);
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Main Loop
|
156
|
+
# Open window with initial window size, title bar,
|
157
|
+
# RGBA display mode, and handle input events.
|
158
|
+
glutInit
|
159
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
160
|
+
glutInitWindowSize(440, 120)
|
161
|
+
glutInitWindowPosition(100, 100)
|
162
|
+
glutCreateWindow($0)
|
163
|
+
myinit()
|
164
|
+
glutDisplayFunc(display)
|
165
|
+
glutReshapeFunc(reshape)
|
166
|
+
glutKeyboardFunc(keyboard)
|
167
|
+
glutMainLoop()
|
@@ -0,0 +1,166 @@
|
|
1
|
+
#
|
2
|
+
# (c) Copyright 1993, 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(TM) is a trademark of Silicon Graphics, Inc.
|
36
|
+
#
|
37
|
+
#
|
38
|
+
# surface.c
|
39
|
+
# This program draws a NURBS surface in the shape of a
|
40
|
+
# symmetrical hill.
|
41
|
+
#
|
42
|
+
require 'opengl'
|
43
|
+
include Gl,Glu,Glut
|
44
|
+
|
45
|
+
$ctlpoints = Array.new(4).collect { Array.new(4).collect { Array.new(3, nil) } } # 4*4*3 array
|
46
|
+
$showPoints = 0
|
47
|
+
|
48
|
+
$theNurb = nil
|
49
|
+
|
50
|
+
# Initializes the control points of the surface to a small hill.
|
51
|
+
# The control points range from -3 to +3 in x, y, and z
|
52
|
+
def init_surface
|
53
|
+
for u in 0..3
|
54
|
+
for v in 0..3
|
55
|
+
$ctlpoints[u][v][0] = 2.0*(u - 1.5)
|
56
|
+
$ctlpoints[u][v][1] = 2.0*(v - 1.5)
|
57
|
+
|
58
|
+
if ( (u == 1 || u == 2) && (v == 1 || v == 2))
|
59
|
+
$ctlpoints[u][v][2] = 3
|
60
|
+
else
|
61
|
+
$ctlpoints[u][v][2] = -3
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Initialize material property and depth buffer.
|
68
|
+
def myinit
|
69
|
+
mat_diffuse = [ 0.7, 0.7, 0.7, 1.0 ]
|
70
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
71
|
+
mat_shininess = [ 100.0 ]
|
72
|
+
|
73
|
+
glClearColor(0.0, 0.0, 0.0, 1.0)
|
74
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
75
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
76
|
+
glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
|
77
|
+
|
78
|
+
glEnable(GL_LIGHTING)
|
79
|
+
glEnable(GL_LIGHT0)
|
80
|
+
glDepthFunc(GL_LESS)
|
81
|
+
glEnable(GL_DEPTH_TEST)
|
82
|
+
glEnable(GL_AUTO_NORMAL)
|
83
|
+
glEnable(GL_NORMALIZE)
|
84
|
+
|
85
|
+
init_surface()
|
86
|
+
|
87
|
+
$theNurb = gluNewNurbsRenderer()
|
88
|
+
gluNurbsProperty($theNurb, GLU_SAMPLING_TOLERANCE, 25.0)
|
89
|
+
gluNurbsProperty($theNurb, GLU_DISPLAY_MODE, GLU_FILL)
|
90
|
+
end
|
91
|
+
|
92
|
+
display = Proc.new do
|
93
|
+
knots = [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
|
94
|
+
|
95
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
96
|
+
|
97
|
+
glPushMatrix()
|
98
|
+
glRotate(330.0, 1.0,0.0,0.0)
|
99
|
+
glScale(0.5, 0.5, 0.5)
|
100
|
+
|
101
|
+
gluBeginSurface($theNurb)
|
102
|
+
gluNurbsSurface($theNurb,
|
103
|
+
8, knots,
|
104
|
+
8, knots,
|
105
|
+
4 * 3,
|
106
|
+
3,
|
107
|
+
$ctlpoints.flatten,
|
108
|
+
4, 4,
|
109
|
+
GL_MAP2_VERTEX_3)
|
110
|
+
gluEndSurface($theNurb)
|
111
|
+
|
112
|
+
if($showPoints==1)
|
113
|
+
glPointSize(5.0)
|
114
|
+
glDisable(GL_LIGHTING)
|
115
|
+
glColor(1.0, 1.0, 0.0)
|
116
|
+
glBegin(GL_POINTS)
|
117
|
+
for i in 0..3
|
118
|
+
for j in 0..3
|
119
|
+
glVertex($ctlpoints[i][j][0], $ctlpoints[i][j][1], $ctlpoints[i][j][2])
|
120
|
+
end
|
121
|
+
end
|
122
|
+
glEnd()
|
123
|
+
glEnable(GL_LIGHTING)
|
124
|
+
end
|
125
|
+
|
126
|
+
glPopMatrix()
|
127
|
+
glutSwapBuffers()
|
128
|
+
end
|
129
|
+
|
130
|
+
reshape = Proc.new do |w, h|
|
131
|
+
glViewport(0, 0, w, h)
|
132
|
+
glMatrixMode(GL_PROJECTION)
|
133
|
+
glLoadIdentity()
|
134
|
+
gluPerspective(45.0, w/h, 3.0, 8.0)
|
135
|
+
|
136
|
+
glMatrixMode(GL_MODELVIEW)
|
137
|
+
glLoadIdentity()
|
138
|
+
glTranslate(0.0, 0.0, -5.0)
|
139
|
+
end
|
140
|
+
|
141
|
+
menu = Proc.new do |value|
|
142
|
+
$showPoints = value
|
143
|
+
glutPostRedisplay()
|
144
|
+
end
|
145
|
+
|
146
|
+
keyboard = Proc.new do |key, x, y|
|
147
|
+
case (key)
|
148
|
+
when ?\e
|
149
|
+
exit(0);
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
glutInit
|
154
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
155
|
+
glutInitWindowSize(500, 500)
|
156
|
+
glutInitWindowPosition(100, 100)
|
157
|
+
glutCreateWindow($0)
|
158
|
+
myinit()
|
159
|
+
glutReshapeFunc(reshape)
|
160
|
+
glutDisplayFunc(display)
|
161
|
+
glutKeyboardFunc(keyboard)
|
162
|
+
glutCreateMenu(menu)
|
163
|
+
glutAddMenuEntry("Show control points", 1)
|
164
|
+
glutAddMenuEntry("Hide control points", 0)
|
165
|
+
glutAttachMenu(GLUT_RIGHT_BUTTON)
|
166
|
+
glutMainLoop()
|