opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/examples/RedBook/robot.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 s and e keys (shoulder and elbow)
|
41
41
|
# alters the rotation of the robot arm.
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
require 'mathn'
|
44
46
|
include Gl,Glu,Glut
|
45
47
|
|
@@ -47,69 +49,69 @@ $shoulder = 0
|
|
47
49
|
$elbow = 0
|
48
50
|
|
49
51
|
def init
|
50
|
-
|
51
|
-
|
52
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
53
|
+
glShadeModel(GL_FLAT)
|
52
54
|
end
|
53
55
|
|
54
56
|
display = Proc.new do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
57
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
58
|
+
glPushMatrix()
|
59
|
+
glTranslate(-1.0, 0.0, 0.0)
|
60
|
+
glRotate($shoulder, 0.0, 0.0, 1.0)
|
61
|
+
glTranslate(1.0, 0.0, 0.0)
|
62
|
+
glPushMatrix()
|
63
|
+
glScale(2.0, 0.4, 1.0)
|
64
|
+
glutWireCube(1.0)
|
65
|
+
glPopMatrix()
|
66
|
+
|
67
|
+
glTranslate(1.0, 0.0, 0.0)
|
68
|
+
glRotate($elbow, 0.0, 0.0, 1.0)
|
69
|
+
glTranslate(1.0, 0.0, 0.0)
|
70
|
+
glPushMatrix()
|
71
|
+
glScale(2.0, 0.4, 1.0)
|
72
|
+
glutWireCube(1.0)
|
73
|
+
glPopMatrix()
|
74
|
+
|
75
|
+
glPopMatrix()
|
76
|
+
glutSwapBuffers()
|
75
77
|
end
|
76
78
|
|
77
79
|
reshape = Proc.new do |w, h|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
glViewport(0, 0, w, h)
|
81
|
+
glMatrixMode(GL_PROJECTION)
|
82
|
+
glLoadIdentity()
|
83
|
+
gluPerspective(65.0, w/ h, 1.0, 20.0)
|
84
|
+
glMatrixMode(GL_MODELVIEW)
|
85
|
+
glLoadIdentity()
|
86
|
+
glTranslate(0.0, 0.0, -5.0)
|
85
87
|
end
|
86
88
|
|
87
89
|
keyboard = Proc.new do|key, x, y|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
90
|
+
case (key)
|
91
|
+
when ?s
|
92
|
+
$shoulder = ($shoulder + 5) % 360
|
93
|
+
glutPostRedisplay()
|
94
|
+
when ?S
|
95
|
+
$shoulder = ($shoulder - 5) % 360
|
96
|
+
glutPostRedisplay()
|
97
|
+
when ?e
|
98
|
+
$elbow = ($elbow + 5) % 360
|
99
|
+
glutPostRedisplay()
|
100
|
+
when ?E
|
101
|
+
$elbow = ($elbow - 5) % 360
|
102
|
+
glutPostRedisplay()
|
103
|
+
when ?\e
|
104
|
+
exit(0)
|
105
|
+
end
|
104
106
|
end
|
105
107
|
|
106
108
|
glutInit
|
107
109
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
108
|
-
glutInitWindowSize(500, 500)
|
110
|
+
glutInitWindowSize(500, 500)
|
109
111
|
glutInitWindowPosition(100, 100)
|
110
112
|
glutCreateWindow($0)
|
111
113
|
init()
|
112
|
-
glutDisplayFunc(display)
|
114
|
+
glutDisplayFunc(display)
|
113
115
|
glutReshapeFunc(reshape)
|
114
116
|
glutKeyboardFunc(keyboard)
|
115
117
|
glutMainLoop()
|
data/examples/RedBook/select.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
|
@@ -36,151 +36,153 @@
|
|
36
36
|
#
|
37
37
|
#
|
38
38
|
# select.c
|
39
|
-
# This is an illustration of the selection mode and
|
40
|
-
# name stack, which detects whether objects which collide
|
41
|
-
# with a viewing volume. First, four triangles and a
|
42
|
-
# rectangular box representing a viewing volume are drawn
|
43
|
-
# (drawScene routine). The green triangle and yellow
|
44
|
-
# triangles appear to lie within the viewing volume, but
|
45
|
-
# the red triangle appears to lie outside it. Then the
|
46
|
-
# selection mode is entered (selectObjects routine).
|
47
|
-
# Drawing to the screen ceases. To see if any collisions
|
48
|
-
# occur, the four triangles are called. In this example,
|
49
|
-
# the green triangle causes one hit with the name 1, and
|
39
|
+
# This is an illustration of the selection mode and
|
40
|
+
# name stack, which detects whether objects which collide
|
41
|
+
# with a viewing volume. First, four triangles and a
|
42
|
+
# rectangular box representing a viewing volume are drawn
|
43
|
+
# (drawScene routine). The green triangle and yellow
|
44
|
+
# triangles appear to lie within the viewing volume, but
|
45
|
+
# the red triangle appears to lie outside it. Then the
|
46
|
+
# selection mode is entered (selectObjects routine).
|
47
|
+
# Drawing to the screen ceases. To see if any collisions
|
48
|
+
# occur, the four triangles are called. In this example,
|
49
|
+
# the green triangle causes one hit with the name 1, and
|
50
50
|
# the yellow triangles cause one hit with the name 3.
|
51
51
|
require 'opengl'
|
52
|
+
require 'glu'
|
53
|
+
require 'glut'
|
52
54
|
include Gl,Glu,Glut
|
53
55
|
|
54
|
-
# draw a triangle with vertices at (x1, y1), (x2, y2)
|
56
|
+
# draw a triangle with vertices at (x1, y1), (x2, y2)
|
55
57
|
# and (x3, y3) at z units away from the origin.
|
56
58
|
def drawTriangle(x1, y1, x2, y2, x3, y3, z)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
glBegin(GL_TRIANGLES)
|
60
|
+
glVertex(x1, y1, z)
|
61
|
+
glVertex(x2, y2, z)
|
62
|
+
glVertex(x3, y3, z)
|
63
|
+
glEnd()
|
62
64
|
end
|
63
65
|
|
64
66
|
# draw a rectangular box with these outer x, y, and z values
|
65
67
|
def drawViewVolume(x1, x2, y1, y2, z1, z2)
|
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
|
-
|
68
|
+
glColor(1.0, 1.0, 1.0)
|
69
|
+
glBegin(GL_LINE_LOOP)
|
70
|
+
glVertex(x1, y1, -z1)
|
71
|
+
glVertex(x2, y1, -z1)
|
72
|
+
glVertex(x2, y2, -z1)
|
73
|
+
glVertex(x1, y2, -z1)
|
74
|
+
glEnd()
|
75
|
+
|
76
|
+
glBegin(GL_LINE_LOOP)
|
77
|
+
glVertex(x1, y1, -z2)
|
78
|
+
glVertex(x2, y1, -z2)
|
79
|
+
glVertex(x2, y2, -z2)
|
80
|
+
glVertex(x1, y2, -z2)
|
81
|
+
glEnd()
|
82
|
+
|
83
|
+
glBegin(GL_LINES)# 4 lines
|
84
|
+
glVertex(x1, y1, -z1)
|
85
|
+
glVertex(x1, y1, -z2)
|
86
|
+
glVertex(x1, y2, -z1)
|
87
|
+
glVertex(x1, y2, -z2)
|
88
|
+
glVertex(x2, y1, -z1)
|
89
|
+
glVertex(x2, y1, -z2)
|
90
|
+
glVertex(x2, y2, -z1)
|
91
|
+
glVertex(x2, y2, -z2)
|
92
|
+
glEnd()
|
91
93
|
end
|
92
94
|
|
93
95
|
# drawScene draws 4 triangles and a wire frame
|
94
96
|
# which represents the viewing volume.
|
95
97
|
def drawScene()
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
98
|
+
glMatrixMode(GL_PROJECTION)
|
99
|
+
glLoadIdentity()
|
100
|
+
gluPerspective(40.0, 4.0/3.0, 1.0, 100.0)
|
101
|
+
|
102
|
+
glMatrixMode(GL_MODELVIEW)
|
103
|
+
glLoadIdentity()
|
104
|
+
gluLookAt(7.5, 7.5, 12.5, 2.5, 2.5, -5.0, 0.0, 1.0, 0.0)
|
105
|
+
glColor(0.0, 1.0, 0.0)# green triangle
|
106
|
+
drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0)
|
107
|
+
glColor(1.0, 0.0, 0.0)# red triangle
|
108
|
+
drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0)
|
109
|
+
glColor(1.0, 1.0, 0.0)# yellow triangles
|
110
|
+
drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0)
|
111
|
+
drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0)
|
112
|
+
drawViewVolume(0.0, 5.0, 0.0, 5.0, 0.0, 10.0)
|
111
113
|
end
|
112
114
|
|
113
115
|
# processHits prints out the contents of the selection array
|
114
116
|
def processHits(hits, buffer)
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
117
|
+
printf("hits = %d\n", hits)
|
118
|
+
ptr = buffer.unpack("I*")
|
119
|
+
p = 0
|
120
|
+
for i in 0...hits # for each hit
|
121
|
+
names = ptr[p]
|
122
|
+
printf(" number of names for hit = %d\n", names); p+=1
|
123
|
+
printf(" z1 is %g", ptr[p].to_f/0xffffffff); p+=1
|
124
|
+
printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1
|
125
|
+
printf(" the name is ")
|
126
|
+
for j in 0...names # for each name
|
127
|
+
printf("%d ", ptr[p]); p+=1
|
128
|
+
end
|
129
|
+
printf("\n")
|
130
|
+
end
|
129
131
|
end
|
130
132
|
|
131
|
-
# selectObjects "draws" the triangles in selection mode,
|
133
|
+
# selectObjects "draws" the triangles in selection mode,
|
132
134
|
# assigning names for the triangles. Note that the third
|
133
|
-
# and fourth triangles share one name, so that if either
|
134
|
-
# or both triangles intersects the viewing/clipping volume,
|
135
|
+
# and fourth triangles share one name, so that if either
|
136
|
+
# or both triangles intersects the viewing/clipping volume,
|
135
137
|
# only one hit will be registered.
|
136
138
|
|
137
139
|
BUFSIZE=512
|
138
140
|
|
139
141
|
def selectObjects
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
142
|
+
selectBuf = glSelectBuffer(BUFSIZE)
|
143
|
+
glRenderMode(GL_SELECT)
|
144
|
+
|
145
|
+
glInitNames()
|
146
|
+
glPushName(0)
|
147
|
+
|
148
|
+
glPushMatrix()
|
149
|
+
glMatrixMode(GL_PROJECTION)
|
150
|
+
glLoadIdentity()
|
151
|
+
glOrtho(0.0, 5.0, 0.0, 5.0, 0.0, 10.0)
|
152
|
+
glMatrixMode(GL_MODELVIEW)
|
153
|
+
glLoadIdentity()
|
154
|
+
glLoadName(1)
|
155
|
+
drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0)
|
156
|
+
glLoadName(2)
|
157
|
+
drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0)
|
158
|
+
glLoadName(3)
|
159
|
+
drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0)
|
160
|
+
drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0)
|
161
|
+
glPopMatrix()
|
162
|
+
glFlush()
|
163
|
+
|
164
|
+
hits = glRenderMode(GL_RENDER)
|
165
|
+
processHits(hits, selectBuf)
|
166
|
+
end
|
165
167
|
|
166
168
|
def init
|
167
|
-
|
168
|
-
|
169
|
+
glEnable(GL_DEPTH_TEST)
|
170
|
+
glShadeModel(GL_FLAT)
|
169
171
|
end
|
170
172
|
|
171
173
|
display = proc do
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
174
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
175
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
176
|
+
drawScene()
|
177
|
+
selectObjects()
|
178
|
+
glFlush()
|
177
179
|
end
|
178
180
|
|
179
181
|
keyboard = proc do |key, x, y|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
182
|
+
case (key)
|
183
|
+
when ?\e
|
184
|
+
exit(0)
|
185
|
+
end
|
184
186
|
end
|
185
187
|
|
186
188
|
# Main Loop
|
data/examples/RedBook/smooth.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
|
@@ -39,48 +39,50 @@
|
|
39
39
|
# A smooth shaded polygon is drawn in a 2-D projection.
|
40
40
|
|
41
41
|
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
42
44
|
include Gl,Glu,Glut
|
43
45
|
|
44
46
|
def init
|
45
|
-
|
46
|
-
|
47
|
+
glClearColor(0,0,0,0)
|
48
|
+
glShadeModel(GL_SMOOTH)
|
47
49
|
end
|
48
50
|
|
49
51
|
def triangle
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
glBegin(GL_TRIANGLES)
|
53
|
+
glColor3f(1.0, 0.0, 0.0)
|
54
|
+
glVertex2f(5, 5)
|
55
|
+
glColor3f(0.0, 1.0, 0.0)
|
56
|
+
glVertex2f(25, 5)
|
57
|
+
glColor3f(0.0, 0.0, 1.0)
|
58
|
+
glVertex2f(5, 25)
|
59
|
+
glEnd()
|
58
60
|
end
|
59
61
|
|
60
62
|
|
61
|
-
display = Proc.new do
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
display = Proc.new do
|
64
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
65
|
+
triangle
|
66
|
+
glutSwapBuffers()
|
65
67
|
end
|
66
68
|
|
67
69
|
reshape = Proc.new do |w, h|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
glViewport(0, 0, w, h)
|
71
|
+
glMatrixMode(GL_PROJECTION)
|
72
|
+
glLoadIdentity
|
73
|
+
if w<=h
|
74
|
+
gluOrtho2D(0,30,0, 30 * h/w)
|
75
|
+
else
|
76
|
+
gluOrtho2D(0,30 * w/h, 0,30)
|
77
|
+
end
|
78
|
+
glMatrixMode(GL_MODELVIEW)
|
77
79
|
end
|
78
80
|
|
79
81
|
keyboard = lambda do |key, x, y|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
case(key)
|
83
|
+
when ?\e
|
84
|
+
exit(0)
|
85
|
+
end
|
84
86
|
end
|
85
87
|
|
86
88
|
glutInit()
|