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
@@ -0,0 +1,158 @@
|
|
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
|
+
# alpha3D.c
|
38
|
+
# This program demonstrates how to intermix opaque and
|
39
|
+
# alpha blended polygons in the same scene, by using
|
40
|
+
# glDepthMask. Press the 'a' key to animate moving the
|
41
|
+
# transparent object through the opaque object. Press
|
42
|
+
# the 'r' key to reset the scene.
|
43
|
+
require 'opengl'
|
44
|
+
include Gl,Glu,Glut
|
45
|
+
|
46
|
+
MAXZ=1.0
|
47
|
+
MINZ=-2.0
|
48
|
+
ZINC=0.1
|
49
|
+
|
50
|
+
$solidZ = MAXZ
|
51
|
+
$transparentZ = MINZ
|
52
|
+
$sphereList=nil
|
53
|
+
$cubeList=nil
|
54
|
+
|
55
|
+
def init
|
56
|
+
mat_specular = [ 1.0, 1.0, 1.0, 0.15 ]
|
57
|
+
mat_shininess = [ 100.0 ]
|
58
|
+
position = [ 0.5, 0.5, 1.0, 0.0 ]
|
59
|
+
|
60
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
61
|
+
glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
|
62
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
63
|
+
|
64
|
+
glEnable(GL_LIGHTING)
|
65
|
+
glEnable(GL_LIGHT0)
|
66
|
+
glEnable(GL_DEPTH_TEST)
|
67
|
+
|
68
|
+
$sphereList = glGenLists(1)
|
69
|
+
glNewList($sphereList, GL_COMPILE)
|
70
|
+
glutSolidSphere(0.4, 16, 16)
|
71
|
+
glEndList()
|
72
|
+
|
73
|
+
$cubeList = glGenLists(1)
|
74
|
+
glNewList($cubeList, GL_COMPILE)
|
75
|
+
glutSolidCube(0.6)
|
76
|
+
glEndList()
|
77
|
+
end
|
78
|
+
|
79
|
+
display = proc do
|
80
|
+
mat_solid = [ 0.75, 0.75, 0.0, 1.0 ]
|
81
|
+
mat_zero = [ 0.0, 0.0, 0.0, 1.0 ]
|
82
|
+
mat_transparent = [ 0.0, 0.8, 0.8, 0.6 ]
|
83
|
+
mat_emission = [ 0.0, 0.3, 0.3, 0.6 ]
|
84
|
+
|
85
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
86
|
+
|
87
|
+
glPushMatrix()
|
88
|
+
glTranslate(-0.15, -0.15, $solidZ)
|
89
|
+
glMaterial(GL_FRONT, GL_EMISSION, mat_zero)
|
90
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_solid)
|
91
|
+
glCallList($sphereList)
|
92
|
+
glPopMatrix()
|
93
|
+
|
94
|
+
glPushMatrix()
|
95
|
+
glTranslate(0.15, 0.15, $transparentZ)
|
96
|
+
glRotate(15.0, 1.0, 1.0, 0.0)
|
97
|
+
glRotate(30.0, 0.0, 1.0, 0.0)
|
98
|
+
glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
|
99
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_transparent)
|
100
|
+
glEnable(GL_BLEND)
|
101
|
+
glDepthMask(GL_FALSE)
|
102
|
+
glBlendFunc(GL_SRC_ALPHA, GL_ONE)
|
103
|
+
glCallList($cubeList)
|
104
|
+
glDepthMask(GL_TRUE)
|
105
|
+
glDisable(GL_BLEND)
|
106
|
+
glPopMatrix()
|
107
|
+
|
108
|
+
glutSwapBuffers()
|
109
|
+
end
|
110
|
+
|
111
|
+
reshape = proc do |w, h|
|
112
|
+
glViewport(0, 0, w, h)
|
113
|
+
glMatrixMode(GL_PROJECTION)
|
114
|
+
glLoadIdentity()
|
115
|
+
if (w <= h)
|
116
|
+
glOrtho(-1.5, 1.5, -1.5*h.to_f/w, 1.5*h.to_f/w, -10.0, 10.0)
|
117
|
+
else
|
118
|
+
glOrtho(-1.5*w.to_f/h, 1.5*w.to_f/h, -1.5, 1.5, -10.0, 10.0)
|
119
|
+
end
|
120
|
+
glMatrixMode(GL_MODELVIEW)
|
121
|
+
glLoadIdentity()
|
122
|
+
end
|
123
|
+
|
124
|
+
animate = proc do
|
125
|
+
if ($solidZ <= MINZ || $transparentZ >= MAXZ)
|
126
|
+
glutIdleFunc(nil)
|
127
|
+
else
|
128
|
+
$solidZ -= ZINC
|
129
|
+
$transparentZ += ZINC
|
130
|
+
glutPostRedisplay()
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
keyboard = proc do |key, x, y|
|
135
|
+
case (key)
|
136
|
+
when ?a,?A
|
137
|
+
$solidZ = MAXZ
|
138
|
+
$transparentZ = MINZ
|
139
|
+
glutIdleFunc(animate)
|
140
|
+
when ?r, ?R
|
141
|
+
$solidZ = MAXZ
|
142
|
+
$transparentZ = MINZ
|
143
|
+
glutPostRedisplay()
|
144
|
+
when 27
|
145
|
+
exit(0)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
glutInit()
|
150
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
151
|
+
glutInitWindowSize(500, 500)
|
152
|
+
glutInitWindowPosition(100, 100)
|
153
|
+
glutCreateWindow($0)
|
154
|
+
init()
|
155
|
+
glutReshapeFunc(reshape)
|
156
|
+
glutKeyboardFunc(keyboard)
|
157
|
+
glutDisplayFunc(display)
|
158
|
+
glutMainLoop()
|
@@ -0,0 +1,105 @@
|
|
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
|
+
# bezcurve.c
|
38
|
+
# This program uses evaluators to draw a Bezier curve.
|
39
|
+
|
40
|
+
require "opengl"
|
41
|
+
include Gl,Glu,Glut
|
42
|
+
|
43
|
+
$ctrlpoints = [
|
44
|
+
[-4.0,-4.0, 0.0],
|
45
|
+
[-2.0, 4.0, 0.0],
|
46
|
+
[ 2.0,-4.0, 0.0],
|
47
|
+
[ 4.0, 4.0, 0.0]
|
48
|
+
]
|
49
|
+
|
50
|
+
def init
|
51
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
52
|
+
glShadeModel(GL_FLAT)
|
53
|
+
glMap1d(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, $ctrlpoints.flatten)
|
54
|
+
glEnable(GL_MAP1_VERTEX_3)
|
55
|
+
end
|
56
|
+
|
57
|
+
display = proc do
|
58
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
59
|
+
glColor(1.0, 1.0, 1.0)
|
60
|
+
glBegin(GL_LINE_STRIP)
|
61
|
+
for i in 0..30
|
62
|
+
glEvalCoord1d(i.to_f/30.0)
|
63
|
+
end
|
64
|
+
glEnd()
|
65
|
+
# The following code displays the control points as dots.
|
66
|
+
glPointSize(5.0)
|
67
|
+
glColor(1.0, 1.0, 0.0)
|
68
|
+
glBegin(GL_POINTS)
|
69
|
+
for i in 0...4
|
70
|
+
glVertex($ctrlpoints[i])
|
71
|
+
end
|
72
|
+
glEnd()
|
73
|
+
glutSwapBuffers()
|
74
|
+
end
|
75
|
+
|
76
|
+
reshape = proc do |w, h|
|
77
|
+
glViewport(0, 0, w, h)
|
78
|
+
glMatrixMode(GL_PROJECTION)
|
79
|
+
glLoadIdentity()
|
80
|
+
if (w <= h)
|
81
|
+
glOrtho(-5.0, 5.0, -5.0*h/w, 5.0*h/w, -5.0, 5.0)
|
82
|
+
else
|
83
|
+
glOrtho(-5.0*w/h, 5.0*w/h, -5.0, 5.0, -5.0, 5.0)
|
84
|
+
end
|
85
|
+
glMatrixMode(GL_MODELVIEW)
|
86
|
+
glLoadIdentity()
|
87
|
+
end
|
88
|
+
|
89
|
+
keyboard = proc do |key, x, y|
|
90
|
+
case (key)
|
91
|
+
when 27
|
92
|
+
exit(0)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
glutInit()
|
97
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
98
|
+
glutInitWindowSize(500, 500)
|
99
|
+
glutInitWindowPosition(100, 100)
|
100
|
+
glutCreateWindow()
|
101
|
+
init()
|
102
|
+
glutDisplayFunc(display)
|
103
|
+
glutReshapeFunc(reshape)
|
104
|
+
glutKeyboardFunc(keyboard)
|
105
|
+
glutMainLoop()
|
@@ -0,0 +1,137 @@
|
|
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
|
+
# bezsurf.c
|
40
|
+
# This program renders a lighted, filled Bezier surface,
|
41
|
+
# using two-dimensional evaluators.
|
42
|
+
#
|
43
|
+
|
44
|
+
require 'opengl'
|
45
|
+
include Gl,Glu,Glut
|
46
|
+
|
47
|
+
$ctrlpoints = [
|
48
|
+
[
|
49
|
+
[-1.5, -1.5, 4.0],
|
50
|
+
[-0.5, -1.5, 2.0],
|
51
|
+
[0.5, -1.5, -1.0],
|
52
|
+
[1.5, -1.5, 2.0]],
|
53
|
+
[
|
54
|
+
[-1.5, -0.5, 1.0],
|
55
|
+
[-0.5, -0.5, 3.0],
|
56
|
+
[0.5, -0.5, 0.0],
|
57
|
+
[1.5, -0.5, -1.0]],
|
58
|
+
[
|
59
|
+
[-1.5, 0.5, 4.0],
|
60
|
+
[-0.5, 0.5, 0.0],
|
61
|
+
[0.5, 0.5, 3.0],
|
62
|
+
[1.5, 0.5, 4.0]],
|
63
|
+
[
|
64
|
+
[-1.5, 1.5, -2.0],
|
65
|
+
[-0.5, 1.5, -2.0],
|
66
|
+
[0.5, 1.5, 0.0],
|
67
|
+
[1.5, 1.5, -1.0]]
|
68
|
+
]
|
69
|
+
|
70
|
+
def initlights
|
71
|
+
ambient = [0.2, 0.2, 0.2, 1.0]
|
72
|
+
position = [0.0, 0.0, 2.0, 1.0]
|
73
|
+
mat_diffuse = [0.6, 0.6, 0.6, 1.0]
|
74
|
+
mat_specular = [1.0, 1.0, 1.0, 1.0]
|
75
|
+
mat_shininess = [50.0]
|
76
|
+
|
77
|
+
glEnable(GL_LIGHTING)
|
78
|
+
glEnable(GL_LIGHT0)
|
79
|
+
|
80
|
+
glLight(GL_LIGHT0, GL_AMBIENT, ambient)
|
81
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
82
|
+
|
83
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
84
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
85
|
+
glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
|
86
|
+
end
|
87
|
+
|
88
|
+
display = proc do
|
89
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
90
|
+
glPushMatrix()
|
91
|
+
glRotate(85.0, 1.0, 1.0, 1.0)
|
92
|
+
glEvalMesh2(GL_FILL, 0, 20, 0, 20)
|
93
|
+
glPopMatrix()
|
94
|
+
glutSwapBuffers()
|
95
|
+
end
|
96
|
+
|
97
|
+
def myinit
|
98
|
+
glClearColor(0.0, 0.0, 0.0, 1.0)
|
99
|
+
glEnable(GL_DEPTH_TEST)
|
100
|
+
glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints.flatten)
|
101
|
+
glEnable(GL_MAP2_VERTEX_3)
|
102
|
+
glEnable(GL_AUTO_NORMAL)
|
103
|
+
glEnable(GL_NORMALIZE)
|
104
|
+
glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
|
105
|
+
initlights() # for lighted version only
|
106
|
+
end
|
107
|
+
|
108
|
+
myReshape = proc do |w, h|
|
109
|
+
glViewport(0, 0, w, h)
|
110
|
+
glMatrixMode(GL_PROJECTION)
|
111
|
+
glLoadIdentity()
|
112
|
+
if (w <= h)
|
113
|
+
glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -4.0, 4.0)
|
114
|
+
else
|
115
|
+
glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -4.0, 4.0)
|
116
|
+
end
|
117
|
+
glMatrixMode(GL_MODELVIEW)
|
118
|
+
glLoadIdentity()
|
119
|
+
end
|
120
|
+
|
121
|
+
keyboard = Proc.new do |key, x, y|
|
122
|
+
case (key)
|
123
|
+
when 27
|
124
|
+
exit(0);
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
glutInit()
|
129
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
130
|
+
glutInitWindowSize(500, 500)
|
131
|
+
glutInitWindowPosition(100, 100)
|
132
|
+
glutCreateWindow($0)
|
133
|
+
myinit()
|
134
|
+
glutReshapeFunc(myReshape)
|
135
|
+
glutDisplayFunc(display)
|
136
|
+
glutKeyboardFunc(keyboard)
|
137
|
+
glutMainLoop()
|
@@ -0,0 +1,124 @@
|
|
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
|
+
# checker.c
|
40
|
+
# This program texture maps a checkerboard image onto
|
41
|
+
# two rectangles. This program clamps the texture, if
|
42
|
+
# the texture coordinates fall outside 0.0 and 1.0.
|
43
|
+
require 'opengl'
|
44
|
+
require 'mathn'
|
45
|
+
include Gl,Glu,Glut
|
46
|
+
|
47
|
+
# Create checkerboard texture
|
48
|
+
CheckImageWidth=64
|
49
|
+
CheckImageHeight=64
|
50
|
+
$checkImage = []
|
51
|
+
|
52
|
+
def makeCheckImage
|
53
|
+
for i in 0..CheckImageWidth-1
|
54
|
+
for j in 0..CheckImageHeight-1
|
55
|
+
c = if ((i&0x8==0) != (j&0x8==0)) then 255 else 0 end
|
56
|
+
$checkImage[(i+CheckImageWidth*j)*3+0] = c
|
57
|
+
$checkImage[(i+CheckImageWidth*j)*3+1] = c
|
58
|
+
$checkImage[(i+CheckImageWidth*j)*3+2] = c
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def myinit
|
64
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
65
|
+
glEnable(GL_DEPTH_TEST)
|
66
|
+
glDepthFunc(GL_LESS)
|
67
|
+
|
68
|
+
makeCheckImage()
|
69
|
+
glPixelStore(GL_UNPACK_ALIGNMENT, 1)
|
70
|
+
glTexImage2D(GL_TEXTURE_2D, 0, 3, CheckImageWidth,
|
71
|
+
CheckImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
|
72
|
+
$checkImage.pack("C*"))
|
73
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
|
74
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
|
75
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
|
76
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
|
77
|
+
glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
|
78
|
+
glEnable(GL_TEXTURE_2D)
|
79
|
+
glShadeModel(GL_FLAT)
|
80
|
+
end
|
81
|
+
|
82
|
+
display = Proc.new do
|
83
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
84
|
+
glBegin(GL_QUADS)
|
85
|
+
glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
|
86
|
+
glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
|
87
|
+
glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
|
88
|
+
glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
|
89
|
+
|
90
|
+
glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
|
91
|
+
glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
|
92
|
+
glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
|
93
|
+
glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
|
94
|
+
glEnd()
|
95
|
+
glutSwapBuffers()
|
96
|
+
end
|
97
|
+
|
98
|
+
myReshape = Proc.new do |w, h|
|
99
|
+
glViewport(0, 0, w, h)
|
100
|
+
glMatrixMode(GL_PROJECTION)
|
101
|
+
glLoadIdentity()
|
102
|
+
gluPerspective(60.0, 1.0*w/h, 1.0, 30.0)
|
103
|
+
glMatrixMode(GL_MODELVIEW)
|
104
|
+
glLoadIdentity()
|
105
|
+
glTranslate(0.0, 0.0, -3.6)
|
106
|
+
end
|
107
|
+
|
108
|
+
keyboard = Proc.new do |key, x, y|
|
109
|
+
case (key)
|
110
|
+
when 27
|
111
|
+
exit(0)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
glutInit
|
116
|
+
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
117
|
+
glutInitWindowSize(500, 500)
|
118
|
+
glutInitWindowPosition(100, 100)
|
119
|
+
glutCreateWindow("checker")
|
120
|
+
myinit()
|
121
|
+
glutReshapeFunc(myReshape)
|
122
|
+
glutDisplayFunc(display)
|
123
|
+
glutKeyboardFunc(keyboard)
|
124
|
+
glutMainLoop()
|