opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +2 -1
- data/.travis.yml +19 -0
- data/History.rdoc +26 -0
- data/Manifest.txt +3 -23
- data/README.rdoc +43 -37
- data/Rakefile +6 -62
- data/examples/NeHe/nehe_lesson02.rb +3 -2
- data/examples/NeHe/nehe_lesson03.rb +3 -2
- data/examples/NeHe/nehe_lesson04.rb +3 -1
- data/examples/NeHe/nehe_lesson05.rb +4 -1
- data/examples/NeHe/nehe_lesson06.rb +9 -6
- data/examples/NeHe/nehe_lesson07.rb +9 -6
- data/examples/NeHe/nehe_lesson08.rb +9 -6
- data/examples/NeHe/nehe_lesson09.rb +10 -6
- data/examples/NeHe/nehe_lesson11.rb +9 -6
- data/examples/NeHe/nehe_lesson12.rb +9 -6
- data/examples/NeHe/nehe_lesson16.rb +50 -47
- data/examples/NeHe/nehe_lesson19.rb +10 -7
- data/examples/NeHe/nehe_lesson36.rb +234 -229
- data/examples/OrangeBook/brick.rb +227 -225
- data/examples/OrangeBook/particle.rb +233 -231
- data/examples/RedBook/aapoly.rb +71 -70
- data/examples/RedBook/aargb.rb +54 -52
- data/examples/RedBook/accanti.rb +96 -94
- data/examples/RedBook/accpersp.rb +106 -104
- data/examples/RedBook/alpha.rb +54 -52
- data/examples/RedBook/alpha3D.rb +90 -88
- data/examples/RedBook/bezcurve.rb +48 -46
- data/examples/RedBook/bezmesh.rb +71 -69
- data/examples/RedBook/checker.rb +57 -55
- data/examples/RedBook/clip.rb +41 -39
- data/examples/RedBook/colormat.rb +72 -70
- data/examples/RedBook/cube.rb +39 -37
- data/examples/RedBook/depthcue.rb +37 -35
- data/examples/RedBook/dof.rb +110 -109
- data/examples/RedBook/double.rb +40 -38
- data/examples/RedBook/drawf.rb +30 -28
- data/examples/RedBook/feedback.rb +79 -77
- data/examples/RedBook/fog.rb +90 -89
- data/examples/RedBook/font.rb +78 -76
- data/examples/RedBook/hello.rb +29 -27
- data/examples/RedBook/image.rb +57 -55
- data/examples/RedBook/jitter.rb +131 -131
- data/examples/RedBook/light.rb +2 -1
- data/examples/RedBook/lines.rb +70 -68
- data/examples/RedBook/list.rb +48 -46
- data/examples/RedBook/material.rb +200 -199
- data/examples/RedBook/mipmap.rb +84 -82
- data/examples/RedBook/model.rb +55 -53
- data/examples/RedBook/movelight.rb +52 -50
- data/examples/RedBook/pickdepth.rb +103 -101
- data/examples/RedBook/planet.rb +46 -44
- data/examples/RedBook/quadric.rb +97 -95
- data/examples/RedBook/robot.rb +55 -53
- data/examples/RedBook/select.rb +118 -116
- data/examples/RedBook/smooth.rb +35 -33
- data/examples/RedBook/stencil.rb +96 -94
- data/examples/RedBook/stroke.rb +75 -73
- data/examples/RedBook/surface.rb +93 -91
- data/examples/RedBook/teaambient.rb +71 -69
- data/examples/RedBook/teapots.rb +105 -103
- data/examples/RedBook/tess.rb +96 -94
- data/examples/RedBook/texbind.rb +79 -77
- data/examples/RedBook/texgen.rb +88 -86
- data/examples/RedBook/texturesurf.rb +57 -55
- data/examples/RedBook/varray.rb +85 -83
- data/examples/RedBook/wrap.rb +76 -74
- data/examples/misc/OGLBench.rb +114 -113
- data/examples/misc/anisotropic.rb +154 -152
- data/examples/misc/fbo_test.rb +37 -36
- data/examples/misc/font-glut.rb +47 -46
- data/examples/misc/glfwtest.rb +16 -16
- data/examples/misc/plane.rb +13 -13
- data/examples/misc/readpixel.rb +66 -65
- data/examples/misc/sdltest.rb +21 -19
- data/examples/misc/trislam.rb +548 -547
- data/ext/opengl/common.h +16 -38
- data/ext/opengl/conv.h +39 -41
- data/ext/opengl/extconf.rb +4 -31
- data/ext/opengl/funcdef.h +126 -124
- data/ext/opengl/gl-1.0-1.1.c +1917 -1917
- data/ext/opengl/gl-1.2.c +4 -667
- data/ext/opengl/gl-1.3.c +9 -9
- data/ext/opengl/gl-1.4.c +8 -8
- data/ext/opengl/gl-1.5.c +1 -1
- data/ext/opengl/gl-2.0.c +392 -388
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +1523 -5
- data/ext/opengl/gl-enums.h +4679 -122
- data/ext/opengl/gl-error.c +7 -7
- data/ext/opengl/gl-error.h +4 -4
- data/ext/opengl/gl-ext-arb.c +468 -464
- data/ext/opengl/gl-ext-ext.c +18 -18
- data/ext/opengl/gl-ext-nv.c +15 -15
- data/ext/opengl/gl.c +2 -0
- data/ext/opengl/gl_buffer.c +92 -92
- data/ext/opengl/opengl.c +1 -7
- data/lib/opengl.rb +23 -59
- data/lib/opengl/1.9/opengl.so +0 -0
- data/lib/opengl/2.0/opengl.so +0 -0
- data/lib/opengl/2.1/opengl.so +0 -0
- data/lib/opengl/test_case.rb +1 -2
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +18 -22
- data/test/test_gl_10_11.rb +220 -220
- data/test/test_gl_12.rb +11 -122
- data/test/test_gl_13.rb +202 -210
- data/test/test_gl_14.rb +16 -19
- data/test/test_gl_15.rb +2 -4
- data/test/test_gl_20.rb +45 -58
- data/test/test_gl_21.rb +46 -163
- data/test/test_gl_ext_arb.rb +54 -72
- data/test/test_gl_ext_ati.rb +0 -2
- data/test/test_gl_ext_ext.rb +66 -66
- data/test/test_gl_ext_gremedy.rb +8 -15
- data/test/test_gl_ext_nv.rb +109 -112
- data/test/test_opengl_buffer.rb +8 -25
- data/utils/README +0 -5
- data/utils/enumgen.rb +72 -76
- data/utils/extlistgen.rb +55 -55
- metadata +90 -67
- metadata.gz.sig +0 -0
- data/Rakefile.cross +0 -107
- data/docs/build_install.txt +0 -119
- data/docs/extensions.txt.in +0 -348
- data/docs/history.txt +0 -66
- data/docs/requirements_and_design.txt +0 -117
- data/docs/roadmap.txt +0 -28
- data/docs/scientific_use.txt +0 -35
- data/docs/supplies/page_template.html +0 -71
- data/docs/thanks.txt +0 -29
- data/docs/tutorial.txt +0 -469
- data/ext/opengl/glu-enums.c +0 -164
- data/ext/opengl/glu-enums.h +0 -463
- data/ext/opengl/glu.c +0 -1534
- data/ext/opengl/glut.c +0 -1145
- data/ext/opengl/glut_callbacks.c +0 -845
- data/lib/glu.rb +0 -1
- data/lib/glut.rb +0 -1
- data/lib/opengl/opengl.so +0 -0
- data/test/test_glu.rb +0 -309
- data/utils/mkdn2html.rb +0 -59
- data/utils/post-mkdn2html.rb +0 -91
- data/website/images/ogl.jpg +0 -0
- data/website/images/tab_bottom.gif +0 -0
- data/website/style.css +0 -198
@@ -3,14 +3,14 @@
|
|
3
3
|
#
|
4
4
|
#
|
5
5
|
# (c) Copyright 1993, Silicon Graphics, Inc.
|
6
|
-
# ALL RIGHTS RESERVED
|
7
|
-
# Permission to use, copy, modify, and distribute this software for
|
6
|
+
# ALL RIGHTS RESERVED
|
7
|
+
# Permission to use, copy, modify, and distribute this software for
|
8
8
|
# any purpose and without fee is hereby granted, provided that the above
|
9
9
|
# copyright notice appear in all copies and that both the copyright notice
|
10
|
-
# and this permission notice appear in supporting documentation, and that
|
10
|
+
# and this permission notice appear in supporting documentation, and that
|
11
11
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
12
12
|
# or publicity pertaining to distribution of the software without specific,
|
13
|
-
# written prior permission.
|
13
|
+
# written prior permission.
|
14
14
|
#
|
15
15
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
16
16
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -24,8 +24,8 @@
|
|
24
24
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
25
25
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
26
26
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
27
|
-
#
|
28
|
-
# US Government Users Restricted Rights
|
27
|
+
#
|
28
|
+
# US Government Users Restricted Rights
|
29
29
|
# Use, duplication, or disclosure by the Government is subject to
|
30
30
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
31
31
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -38,133 +38,135 @@
|
|
38
38
|
# OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
39
39
|
#
|
40
40
|
# pickdepth.c
|
41
|
-
# Picking is demonstrated in this program. In
|
42
|
-
# rendering mode, three overlapping rectangles are
|
43
|
-
# drawn. When the left mouse button is pressed,
|
44
|
-
# selection mode is entered with the picking matrix.
|
41
|
+
# Picking is demonstrated in this program. In
|
42
|
+
# rendering mode, three overlapping rectangles are
|
43
|
+
# drawn. When the left mouse button is pressed,
|
44
|
+
# selection mode is entered with the picking matrix.
|
45
45
|
# Rectangles which are drawn under the cursor position
|
46
|
-
# are "picked." Pay special attention to the depth
|
46
|
+
# are "picked." Pay special attention to the depth
|
47
47
|
# value range, which is returned.
|
48
48
|
require 'opengl'
|
49
|
+
require 'glu'
|
50
|
+
require 'glut'
|
49
51
|
include Gl,Glu,Glut
|
50
52
|
|
51
53
|
def myinit
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
55
|
+
glDepthFunc(GL_LESS)
|
56
|
+
glEnable(GL_DEPTH_TEST)
|
57
|
+
glShadeModel(GL_FLAT)
|
58
|
+
glDepthRange(0.0, 1.0) #/* The default z mapping */
|
57
59
|
end
|
58
60
|
|
59
|
-
# The three rectangles are drawn. In selection mode,
|
60
|
-
# each rectangle is given the same name. Note that
|
61
|
+
# The three rectangles are drawn. In selection mode,
|
62
|
+
# each rectangle is given the same name. Note that
|
61
63
|
# each rectangle is drawn with a different z value.
|
62
64
|
def drawRects(mode)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
65
|
+
if (mode == GL_SELECT)
|
66
|
+
glLoadName(1)
|
67
|
+
end
|
68
|
+
glBegin(GL_QUADS)
|
69
|
+
glColor(1.0, 1.0, 0.0)
|
70
|
+
glVertex(2, 0, 0)
|
71
|
+
glVertex(2, 6, 0)
|
72
|
+
glVertex(6, 6, 0)
|
73
|
+
glVertex(6, 0, 0)
|
74
|
+
glEnd()
|
75
|
+
if (mode == GL_SELECT)
|
76
|
+
glLoadName(2)
|
77
|
+
end
|
78
|
+
glBegin(GL_QUADS)
|
79
|
+
glColor(0.0, 1.0, 1.0)
|
80
|
+
glVertex(3, 2, -1)
|
81
|
+
glVertex(3, 8, -1)
|
82
|
+
glVertex(8, 8, -1)
|
83
|
+
glVertex(8, 2, -1)
|
84
|
+
glEnd()
|
85
|
+
if (mode == GL_SELECT)
|
86
|
+
glLoadName(3)
|
87
|
+
end
|
88
|
+
glBegin(GL_QUADS)
|
89
|
+
glColor(1.0, 0.0, 1.0)
|
90
|
+
glVertex(0, 2, -2)
|
91
|
+
glVertex(0, 7, -2)
|
92
|
+
glVertex(5, 7, -2)
|
93
|
+
glVertex(5, 2, -2)
|
94
|
+
glEnd()
|
93
95
|
end
|
94
96
|
|
95
|
-
# processHits() prints out the contents of the
|
97
|
+
# processHits() prints out the contents of the
|
96
98
|
# selection array.
|
97
99
|
def processHits(hits, buffer)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
100
|
+
printf("hits = %d\n", hits)
|
101
|
+
ptr = buffer.unpack("I*")
|
102
|
+
p = 0
|
103
|
+
for i in 0...hits # for each hit
|
104
|
+
names = ptr[p]
|
105
|
+
printf(" number of names for hit = %d\n", names); p+=1
|
106
|
+
printf(" z1 is %g", ptr[p].to_f/0xffffffff); p+=1
|
107
|
+
printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1
|
108
|
+
printf(" the name is ")
|
109
|
+
for j in 0...names # for each name
|
110
|
+
printf("%d ", ptr[p]) ; p+=1
|
111
|
+
end
|
112
|
+
printf("\n")
|
113
|
+
end
|
112
114
|
end
|
113
115
|
|
114
|
-
# pickRects() sets up selection mode, name stack,
|
115
|
-
# and projection matrix for picking. Then the objects
|
116
|
+
# pickRects() sets up selection mode, name stack,
|
117
|
+
# and projection matrix for picking. Then the objects
|
116
118
|
# are drawn.
|
117
119
|
BUFSIZE=512
|
118
120
|
|
119
121
|
pickRects = proc do |button, state, x, y|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
122
|
+
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
|
123
|
+
viewport = glGetDoublev(GL_VIEWPORT)
|
124
|
+
|
125
|
+
selectBuf = glSelectBuffer(BUFSIZE)
|
126
|
+
glRenderMode(GL_SELECT)
|
127
|
+
|
128
|
+
glInitNames()
|
129
|
+
glPushName(~0)
|
130
|
+
|
131
|
+
glMatrixMode(GL_PROJECTION)
|
132
|
+
glPushMatrix()
|
133
|
+
glLoadIdentity()
|
134
|
+
# create 5x5 pixel picking region near cursor location
|
135
|
+
gluPickMatrix( x, viewport[3] - y, 5.0, 5.0, viewport)
|
136
|
+
glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
|
137
|
+
drawRects(GL_SELECT)
|
138
|
+
glPopMatrix()
|
139
|
+
glFlush()
|
140
|
+
|
141
|
+
hits = glRenderMode(GL_RENDER)
|
142
|
+
processHits(hits, selectBuf)
|
143
|
+
end
|
142
144
|
end
|
143
145
|
|
144
146
|
display = proc do
|
145
|
-
|
146
|
-
|
147
|
-
|
147
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
148
|
+
drawRects(GL_RENDER)
|
149
|
+
glutSwapBuffers()
|
148
150
|
end
|
149
151
|
|
150
152
|
myReshape = proc do |w, h|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
153
|
+
glViewport(0, 0, w, h)
|
154
|
+
glMatrixMode(GL_PROJECTION)
|
155
|
+
glLoadIdentity()
|
156
|
+
glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5)
|
157
|
+
glMatrixMode(GL_MODELVIEW)
|
158
|
+
glLoadIdentity()
|
157
159
|
end
|
158
160
|
|
159
161
|
keyboard = Proc.new do |key, x, y|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
162
|
+
case (key)
|
163
|
+
when ?\e
|
164
|
+
exit(0)
|
165
|
+
end
|
164
166
|
end
|
165
167
|
|
166
168
|
# Main Loop
|
167
|
-
# Open window with initial window size, title bar,
|
169
|
+
# Open window with initial window size, title bar,
|
168
170
|
# RGBA display mode, depth buffer, and handle input events.
|
169
171
|
glutInitWindowSize(500, 500)
|
170
172
|
glutInitWindowPosition(100, 100)
|
data/examples/RedBook/planet.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 1993-1997, Silicon Graphics, Inc.
|
3
|
-
# ALL RIGHTS RESERVED
|
4
|
-
# Permission to use, copy, modify, and distribute this software for
|
3
|
+
# ALL RIGHTS RESERVED
|
4
|
+
# Permission to use, copy, modify, and distribute this software for
|
5
5
|
# any purpose and without fee is hereby granted, provided that the above
|
6
6
|
# copyright notice appear in all copies and that both the copyright notice
|
7
|
-
# and this permission notice appear in supporting documentation, and that
|
7
|
+
# and this permission notice appear in supporting documentation, and that
|
8
8
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
9
9
|
# or publicity pertaining to distribution of the software without specific,
|
10
|
-
# written prior permission.
|
10
|
+
# written prior permission.
|
11
11
|
#
|
12
12
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
13
13
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -21,8 +21,8 @@
|
|
21
21
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
22
22
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
23
23
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
24
|
-
#
|
25
|
-
# US Government Users Restricted Rights
|
24
|
+
#
|
25
|
+
# US Government Users Restricted Rights
|
26
26
|
# Use, duplication, or disclosure by the Government is subject to
|
27
27
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
28
28
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -40,6 +40,8 @@
|
|
40
40
|
# Interaction: pressing the d and y keys (day and year)
|
41
41
|
# alters the rotation of the planet around the sun.
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
require 'rational'
|
44
46
|
include Gl,Glu,Glut
|
45
47
|
|
@@ -49,60 +51,60 @@ $year = 0
|
|
49
51
|
$day = 0
|
50
52
|
|
51
53
|
def init
|
52
|
-
|
53
|
-
|
54
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
55
|
+
glShadeModel(GL_FLAT)
|
54
56
|
end
|
55
57
|
|
56
58
|
display = Proc.new do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
59
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
60
|
+
glColor(1.0, 1.0, 1.0)
|
61
|
+
|
62
|
+
glPushMatrix()
|
63
|
+
glutWireSphere(1.0, 20, 16) # draw sun
|
64
|
+
glRotate($year, 0.0, 1.0, 0.0)
|
65
|
+
glTranslate(2.0, 0.0, 0.0)
|
66
|
+
glRotate($day, 0.0, 1.0, 0.0)
|
67
|
+
glutWireSphere(0.2, 10, 8) # draw smaller planet
|
68
|
+
glPopMatrix()
|
69
|
+
glutSwapBuffers()
|
68
70
|
end
|
69
71
|
|
70
72
|
reshape = Proc.new do |w, h|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
73
|
+
glViewport(0, 0, w, h)
|
74
|
+
glMatrixMode(GL_PROJECTION)
|
75
|
+
glLoadIdentity()
|
76
|
+
gluPerspective(60.0, w.to_f/h.to_f, 1.0, 20.0)
|
77
|
+
glMatrixMode(GL_MODELVIEW)
|
78
|
+
glLoadIdentity()
|
79
|
+
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
|
78
80
|
end
|
79
81
|
|
80
82
|
keyboard = Proc.new do |key, x, y|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
83
|
+
case (key)
|
84
|
+
when ?d
|
85
|
+
$day = ($day + 10) % 360
|
86
|
+
glutPostRedisplay()
|
87
|
+
when ?D
|
88
|
+
$day = ($day - 10) % 360
|
89
|
+
glutPostRedisplay()
|
90
|
+
when ?y
|
91
|
+
$year = ($year + 5) % 360
|
92
|
+
glutPostRedisplay()
|
93
|
+
when ?Y
|
94
|
+
$year = ($year - 5) % 360
|
95
|
+
glutPostRedisplay()
|
96
|
+
when ?\e
|
97
|
+
exit(0)
|
98
|
+
end
|
97
99
|
end
|
98
100
|
|
99
101
|
glutInit
|
100
102
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
101
|
-
glutInitWindowSize(500, 500)
|
103
|
+
glutInitWindowSize(500, 500)
|
102
104
|
glutInitWindowPosition(100, 100)
|
103
105
|
glutCreateWindow($0)
|
104
106
|
init()
|
105
|
-
glutDisplayFunc(display)
|
107
|
+
glutDisplayFunc(display)
|
106
108
|
glutReshapeFunc(reshape)
|
107
109
|
glutKeyboardFunc(keyboard)
|
108
110
|
glutMainLoop()
|
data/examples/RedBook/quadric.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#
|
2
2
|
# Copyright (c) 1993-1997, Silicon Graphics, Inc.
|
3
|
-
# ALL RIGHTS RESERVED
|
4
|
-
# Permission to use, copy, modify, and distribute this software for
|
3
|
+
# ALL RIGHTS RESERVED
|
4
|
+
# Permission to use, copy, modify, and distribute this software for
|
5
5
|
# any purpose and without fee is hereby granted, provided that the above
|
6
6
|
# copyright notice appear in all copies and that both the copyright notice
|
7
|
-
# and this permission notice appear in supporting documentation, and that
|
7
|
+
# and this permission notice appear in supporting documentation, and that
|
8
8
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
9
9
|
# or publicity pertaining to distribution of the software without specific,
|
10
|
-
# written prior permission.
|
10
|
+
# written prior permission.
|
11
11
|
#
|
12
12
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
13
13
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -21,8 +21,8 @@
|
|
21
21
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
22
22
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
23
23
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
24
|
-
#
|
25
|
-
# US Government Users Restricted Rights
|
24
|
+
#
|
25
|
+
# US Government Users Restricted Rights
|
26
26
|
# Use, duplication, or disclosure by the Government is subject to
|
27
27
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
28
28
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -41,118 +41,120 @@
|
|
41
41
|
# Note that the cylinder has no top or bottom and the circle
|
42
42
|
# has a hole in it.
|
43
43
|
require 'opengl'
|
44
|
+
require 'glu'
|
45
|
+
require 'glut'
|
44
46
|
require 'mathn'
|
45
47
|
include Gl,Glu,Glut
|
46
48
|
|
47
49
|
$startList = nil
|
48
50
|
|
49
51
|
def init
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
52
|
+
mat_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
|
53
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
54
|
+
mat_shininess = [ 50.0 ]
|
55
|
+
light_position = [ 1.0, 1.0, 1.0, 0.0 ]
|
56
|
+
model_ambient = [ 0.5, 0.5, 0.5, 1.0 ]
|
57
|
+
|
58
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
59
|
+
|
60
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
|
61
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
62
|
+
glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
|
63
|
+
glLight(GL_LIGHT0, GL_POSITION, light_position)
|
64
|
+
glLightModel(GL_LIGHT_MODEL_AMBIENT, model_ambient)
|
65
|
+
|
66
|
+
glEnable(GL_LIGHTING)
|
67
|
+
glEnable(GL_LIGHT0)
|
68
|
+
glEnable(GL_DEPTH_TEST)
|
69
|
+
|
70
|
+
# Create 4 display lists, each with a different quadric object.
|
71
|
+
# Different drawing styles and surface normal specifications
|
72
|
+
# are demonstrated.
|
73
|
+
$startList = glGenLists(4)
|
74
|
+
qobj = gluNewQuadric()
|
75
|
+
|
76
|
+
gluQuadricDrawStyle(qobj, GLU_FILL) # smooth shaded
|
77
|
+
gluQuadricNormals(qobj, GLU_SMOOTH)
|
78
|
+
glNewList($startList, GL_COMPILE)
|
79
|
+
gluSphere(qobj, 0.75, 15, 10)
|
80
|
+
glEndList()
|
81
|
+
|
82
|
+
gluQuadricDrawStyle(qobj, GLU_FILL) # flat shaded
|
83
|
+
gluQuadricNormals(qobj, GLU_FLAT)
|
84
|
+
glNewList($startList+1, GL_COMPILE)
|
85
|
+
gluCylinder(qobj, 0.5, 0.3, 1.0, 15, 5)
|
86
|
+
glEndList()
|
87
|
+
|
88
|
+
gluQuadricDrawStyle(qobj, GLU_LINE) # all polygons wireframe
|
89
|
+
gluQuadricNormals(qobj, GLU_NONE)
|
90
|
+
glNewList($startList+2, GL_COMPILE)
|
91
|
+
gluDisk(qobj, 0.25, 1.0, 20, 4)
|
92
|
+
glEndList()
|
93
|
+
|
94
|
+
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE) # boundary only
|
95
|
+
gluQuadricNormals(qobj, GLU_NONE)
|
96
|
+
glNewList($startList+3, GL_COMPILE)
|
97
|
+
gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0)
|
98
|
+
glEndList()
|
97
99
|
end
|
98
100
|
|
99
101
|
display = Proc.new do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
102
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
103
|
+
glPushMatrix()
|
104
|
+
|
105
|
+
glEnable(GL_LIGHTING)
|
106
|
+
glShadeModel(GL_SMOOTH)
|
107
|
+
glTranslate(-1.0, -1.0, 0.0)
|
108
|
+
glCallList($startList)
|
109
|
+
|
110
|
+
glShadeModel(GL_FLAT)
|
111
|
+
glTranslate(0.0, 2.0, 0.0)
|
112
|
+
glPushMatrix()
|
113
|
+
glRotate(300.0, 1.0, 0.0, 0.0)
|
114
|
+
glCallList($startList+1)
|
115
|
+
glPopMatrix()
|
116
|
+
|
117
|
+
glDisable(GL_LIGHTING)
|
118
|
+
glColor(0.0, 1.0, 1.0)
|
119
|
+
glTranslate(2.0, -2.0, 0.0)
|
120
|
+
glCallList($startList+2)
|
121
|
+
|
122
|
+
glColor(1.0, 1.0, 0.0)
|
123
|
+
glTranslate(0.0, 2.0, 0.0)
|
124
|
+
glCallList($startList+3)
|
125
|
+
|
126
|
+
glPopMatrix()
|
127
|
+
glutSwapBuffers()
|
126
128
|
end
|
127
129
|
|
128
130
|
reshape = Proc.new do |w, h|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
131
|
+
glViewport(0, 0, w, h)
|
132
|
+
glMatrixMode(GL_PROJECTION)
|
133
|
+
glLoadIdentity()
|
134
|
+
if (w <= h)
|
135
|
+
glOrtho(-2.5, 2.5, -2.5*h/w, 2.5*h/w, -10.0, 10.0)
|
136
|
+
else
|
137
|
+
glOrtho(-2.5*w/h, 2.5*w/h, -2.5, 2.5, -10.0, 10.0)
|
138
|
+
end
|
139
|
+
glMatrixMode(GL_MODELVIEW)
|
140
|
+
glLoadIdentity()
|
139
141
|
end
|
140
142
|
|
141
143
|
keyboard = Proc.new do |key, x, y|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
144
|
+
case (key)
|
145
|
+
when ?\e
|
146
|
+
exit(0)
|
147
|
+
end
|
146
148
|
end
|
147
149
|
|
148
150
|
# main
|
149
151
|
glutInit
|
150
152
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
151
|
-
glutInitWindowSize(500, 500)
|
153
|
+
glutInitWindowSize(500, 500)
|
152
154
|
glutInitWindowPosition(100, 100)
|
153
155
|
glutCreateWindow($0)
|
154
156
|
init()
|
155
|
-
glutDisplayFunc(display)
|
157
|
+
glutDisplayFunc(display)
|
156
158
|
glutReshapeFunc(reshape)
|
157
159
|
glutKeyboardFunc(keyboard)
|
158
160
|
glutMainLoop()
|