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
data/examples/RedBook/light.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# This example comes from the Red Book chapter 5, example 5-1 light.c
|
2
2
|
|
3
3
|
require 'opengl'
|
4
|
+
require 'glu'
|
5
|
+
require 'glut'
|
4
6
|
require 'mathn'
|
5
7
|
|
6
8
|
def init
|
@@ -151,4 +153,3 @@ glutDisplayFunc :display
|
|
151
153
|
glutReshapeFunc :reshape
|
152
154
|
glutKeyboardFunc :keyboard
|
153
155
|
glutMainLoop
|
154
|
-
|
data/examples/RedBook/lines.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
|
@@ -38,91 +38,93 @@
|
|
38
38
|
# This program demonstrates geometric primitives and
|
39
39
|
# their attributes.
|
40
40
|
require 'opengl'
|
41
|
+
require 'glu'
|
42
|
+
require 'glut'
|
41
43
|
require 'mathn'
|
42
44
|
include Gl,Glu,Glut
|
43
45
|
|
44
46
|
def drawOneLine(x1,y1,x2,y2)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
glBegin(GL_LINES)
|
48
|
+
glVertex((x1),(y1))
|
49
|
+
glVertex((x2),(y2))
|
50
|
+
glEnd()
|
49
51
|
end
|
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
|
-
|
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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
59
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
60
|
+
|
61
|
+
# select white for all lines
|
62
|
+
glColor(1.0, 1.0, 1.0)
|
63
|
+
|
64
|
+
# in 1st row, 3 lines, each with a different stipple
|
65
|
+
glEnable(GL_LINE_STIPPLE)
|
66
|
+
|
67
|
+
glLineStipple(1, 0x0101) # dotted
|
68
|
+
drawOneLine(50.0, 125.0, 150.0, 125.0)
|
69
|
+
glLineStipple(1, 0x00FF) # dashed
|
70
|
+
drawOneLine(150.0, 125.0, 250.0, 125.0)
|
71
|
+
glLineStipple(1, 0x1C47) # dash/dot/dash
|
72
|
+
drawOneLine(250.0, 125.0, 350.0, 125.0)
|
73
|
+
|
74
|
+
# in 2nd row, 3 wide lines, each with different stipple
|
75
|
+
glLineWidth(5.0)
|
76
|
+
glLineStipple(1, 0x0101) # dotted
|
77
|
+
drawOneLine(50.0, 100.0, 150.0, 100.0)
|
78
|
+
glLineStipple(1, 0x00FF) # dashed
|
79
|
+
drawOneLine(150.0, 100.0, 250.0, 100.0)
|
80
|
+
glLineStipple(1, 0x1C47) # dash/dot/dash
|
81
|
+
drawOneLine(250.0, 100.0, 350.0, 100.0)
|
82
|
+
glLineWidth(1.0)
|
83
|
+
|
84
|
+
# in 3rd row, 6 lines, with dash/dot/dash stipple
|
85
|
+
# as part of a single connected line strip
|
86
|
+
glLineStipple(1, 0x1C47) # dash/dot/dash
|
87
|
+
glBegin(GL_LINE_STRIP)
|
88
|
+
for i in 0..6
|
89
|
+
glVertex(50.0 + (i * 50.0), 75.0)
|
90
|
+
end
|
91
|
+
glEnd()
|
92
|
+
|
93
|
+
# in 4th row, 6 independent lines with same stipple
|
94
|
+
for i in 0..5
|
95
|
+
drawOneLine(50.0 + (i * 50.0), 50.0, 50.0 + ((i+1) * 50.0), 50.0)
|
96
|
+
end
|
97
|
+
|
98
|
+
# in 5th row, 1 line, with dash/dot/dash stipple
|
99
|
+
# and a stipple repeat factor of 5
|
100
|
+
glLineStipple(5, 0x1C47) # dash/dot/dash
|
101
|
+
drawOneLine(50.0, 25.0, 350.0, 25.0)
|
102
|
+
|
103
|
+
glDisable(GL_LINE_STIPPLE)
|
104
|
+
glutSwapBuffers()
|
103
105
|
end
|
104
106
|
|
105
107
|
reshape = Proc.new do |w, h|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
108
|
+
glViewport(0, 0, w, h)
|
109
|
+
glMatrixMode(GL_PROJECTION)
|
110
|
+
glLoadIdentity()
|
111
|
+
GLU.Ortho2D(0.0, w, 0.0, h)
|
110
112
|
end
|
111
113
|
|
112
114
|
keyboard = Proc.new do |key, x, y|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
115
|
+
case (key)
|
116
|
+
when ?\e
|
117
|
+
exit(0)
|
118
|
+
end
|
117
119
|
end
|
118
120
|
|
119
121
|
glutInit
|
120
122
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
121
|
-
glutInitWindowSize(400, 150)
|
123
|
+
glutInitWindowSize(400, 150)
|
122
124
|
glutInitWindowPosition(100, 100)
|
123
125
|
glutCreateWindow($0)
|
124
126
|
init()
|
125
|
-
glutDisplayFunc(display)
|
127
|
+
glutDisplayFunc(display)
|
126
128
|
glutReshapeFunc(reshape)
|
127
129
|
glutKeyboardFunc(keyboard)
|
128
130
|
glutMainLoop()
|
data/examples/RedBook/list.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
|
@@ -35,69 +35,71 @@
|
|
35
35
|
# OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
|
36
36
|
#
|
37
37
|
# list.c
|
38
|
-
# This program demonstrates how to make and execute a
|
39
|
-
# display list. Note that attributes, such as current
|
38
|
+
# This program demonstrates how to make and execute a
|
39
|
+
# display list. Note that attributes, such as current
|
40
40
|
# color and matrix, are changed.
|
41
41
|
require 'opengl'
|
42
|
+
require 'glu'
|
43
|
+
require 'glut'
|
42
44
|
require 'mathn'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
$listName = 0
|
46
48
|
|
47
49
|
def init
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
$listName = glGenLists(1)
|
51
|
+
glNewList($listName, GL_COMPILE)
|
52
|
+
glColor(1.0, 0.0, 0.0) # /* current color red */
|
53
|
+
glBegin(GL_TRIANGLES)
|
54
|
+
glVertex(0.0, 0.0)
|
55
|
+
glVertex(1.0, 0.0)
|
56
|
+
glVertex(0.0, 1.0)
|
57
|
+
glEnd()
|
58
|
+
glTranslate(1.5, 0.0, 0.0) # /* move position */
|
59
|
+
glEndList()
|
60
|
+
glShadeModel(GL_FLAT)
|
59
61
|
end
|
60
62
|
|
61
63
|
def drawLine
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
glBegin(GL_LINES)
|
65
|
+
glVertex(0.0, 0.5)
|
66
|
+
glVertex(15.0, 0.5)
|
67
|
+
glEnd()
|
66
68
|
end
|
67
69
|
|
68
70
|
display = Proc.new do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
72
|
+
glColor(0.0, 1.0, 0.0) # current color green
|
73
|
+
for i in (0..9 ) # draw 10 triangles
|
74
|
+
glCallList($listName)
|
75
|
+
end
|
76
|
+
drawLine() # is this line green? NO!
|
77
|
+
# where is the line drawn?
|
78
|
+
glutSwapBuffers()
|
77
79
|
end
|
78
80
|
|
79
81
|
reshape = Proc.new do |w, h|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
glViewport(0, 0, w, h)
|
83
|
+
glMatrixMode(GL_PROJECTION)
|
84
|
+
glLoadIdentity()
|
85
|
+
if (w <= h)
|
86
|
+
GLU.Ortho2D(0.0, 2.0, -0.5 * h/w, 1.5 * h/w)
|
87
|
+
else
|
88
|
+
GLU.Ortho2D(0.0, 2.0 * w/h, -0.5, 1.5)
|
89
|
+
end
|
90
|
+
glMatrixMode(GL_MODELVIEW)
|
91
|
+
glLoadIdentity()
|
90
92
|
end
|
91
93
|
|
92
94
|
keyboard = Proc.new do |key, x, y|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
case (key)
|
96
|
+
when ?\e
|
97
|
+
exit(0)
|
98
|
+
end
|
97
99
|
end
|
98
100
|
|
99
101
|
# Main Loop
|
100
|
-
# Open window with initial window size, title bar,
|
102
|
+
# Open window with initial window size, title bar,
|
101
103
|
# RGBA display mode, and handle input events.
|
102
104
|
glutInit
|
103
105
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
|
@@ -2,14 +2,14 @@
|
|
2
2
|
# Copyright (c) Mark J. Kilgard, 1994.
|
3
3
|
#
|
4
4
|
# (c) Copyright 1993, Silicon Graphics, Inc.
|
5
|
-
# ALL RIGHTS RESERVED
|
6
|
-
# Permission to use, copy, modify, and distribute this software for
|
5
|
+
# ALL RIGHTS RESERVED
|
6
|
+
# Permission to use, copy, modify, and distribute this software for
|
7
7
|
# any purpose and without fee is hereby granted, provided that the above
|
8
8
|
# copyright notice appear in all copies and that both the copyright notice
|
9
|
-
# and this permission notice appear in supporting documentation, and that
|
9
|
+
# and this permission notice appear in supporting documentation, and that
|
10
10
|
# the name of Silicon Graphics, Inc. not be used in advertising
|
11
11
|
# or publicity pertaining to distribution of the software without specific,
|
12
|
-
# written prior permission.
|
12
|
+
# written prior permission.
|
13
13
|
#
|
14
14
|
# THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
15
15
|
# AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
@@ -23,8 +23,8 @@
|
|
23
23
|
# ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
24
24
|
# ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
25
25
|
# POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
26
|
-
#
|
27
|
-
# US Government Users Restricted Rights
|
26
|
+
#
|
27
|
+
# US Government Users Restricted Rights
|
28
28
|
# Use, duplication, or disclosure by the Government is subject to
|
29
29
|
# restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
30
30
|
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
@@ -41,33 +41,35 @@
|
|
41
41
|
# Several objects are drawn using different material characteristics.
|
42
42
|
# A single light source illuminates the objects.
|
43
43
|
require 'opengl'
|
44
|
+
require 'glu'
|
45
|
+
require 'glut'
|
44
46
|
include Gl,Glu,Glut
|
45
47
|
|
46
|
-
# Initialize z-buffer, projection matrix, light source,
|
48
|
+
# Initialize z-buffer, projection matrix, light source,
|
47
49
|
# and lighting model. Do not specify a material property here.
|
48
50
|
def myinit
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
51
|
+
ambient = [ 0.0, 0.0, 0.0, 1.0 ]
|
52
|
+
diffuse = [ 1.0, 1.0, 1.0, 1.0 ]
|
53
|
+
position = [ 0.0, 3.0, 2.0, 0.0 ]
|
54
|
+
lmodel_ambient = [ 0.4, 0.4, 0.4, 1.0 ]
|
55
|
+
local_view = [ 0.0 ]
|
56
|
+
|
57
|
+
glEnable(GL_DEPTH_TEST)
|
58
|
+
glDepthFunc(GL_LESS)
|
59
|
+
|
60
|
+
glLight(GL_LIGHT0, GL_AMBIENT, ambient)
|
61
|
+
glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
|
62
|
+
glLight(GL_LIGHT0, GL_POSITION, position)
|
63
|
+
glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
|
64
|
+
glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
|
65
|
+
|
66
|
+
glEnable(GL_LIGHTING)
|
67
|
+
glEnable(GL_LIGHT0)
|
68
|
+
|
69
|
+
glClearColor(0.0, 0.1, 0.1, 0.0)
|
68
70
|
end
|
69
71
|
|
70
|
-
# Draw twelve spheres in 3 rows with 4 columns.
|
72
|
+
# Draw twelve spheres in 3 rows with 4 columns.
|
71
73
|
# The spheres in the first row have materials with no ambient reflection.
|
72
74
|
# The second row has materials with significant ambient reflection.
|
73
75
|
# The third row has materials with colored ambient reflection.
|
@@ -81,186 +83,186 @@ end
|
|
81
83
|
#
|
82
84
|
# glTranslatef() is used to move spheres to their appropriate locations.
|
83
85
|
display = proc do
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
86
|
+
no_mat = [ 0.0, 0.0, 0.0, 1.0 ]
|
87
|
+
mat_ambient = [ 0.7, 0.7, 0.7, 1.0 ]
|
88
|
+
mat_ambient_color = [ 0.8, 0.8, 0.2, 1.0 ]
|
89
|
+
mat_diffuse = [ 0.1, 0.5, 0.8, 1.0 ]
|
90
|
+
mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
|
91
|
+
no_shininess = [ 0.0 ]
|
92
|
+
low_shininess = [ 5.0 ]
|
93
|
+
high_shininess = [ 100.0 ]
|
94
|
+
mat_emission = [0.3, 0.2, 0.2, 0.0]
|
95
|
+
|
96
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
97
|
+
|
98
|
+
# draw sphere in first row, first column
|
99
|
+
# diffuse reflection only no ambient or specular
|
100
|
+
glPushMatrix()
|
101
|
+
glTranslate(-3.75, 3.0, 0.0)
|
102
|
+
glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
|
103
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
104
|
+
glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
|
105
|
+
glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
|
106
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
107
|
+
glutSolidSphere(1.0, 16, 16)
|
108
|
+
glPopMatrix()
|
109
|
+
|
110
|
+
# draw sphere in first row, second column
|
111
|
+
# diffuse and specular reflection low shininess no ambient
|
112
|
+
glPushMatrix()
|
113
|
+
glTranslate(-1.25, 3.0, 0.0)
|
114
|
+
glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
|
115
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
116
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
117
|
+
glMaterial(GL_FRONT, GL_SHININESS, low_shininess)
|
118
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
119
|
+
glutSolidSphere(1.0, 16, 16)
|
120
|
+
glPopMatrix()
|
121
|
+
|
122
|
+
# draw sphere in first row, third column
|
123
|
+
# diffuse and specular reflection high shininess no ambient
|
124
|
+
glPushMatrix()
|
125
|
+
glTranslate(1.25, 3.0, 0.0)
|
126
|
+
glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
|
127
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
128
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
129
|
+
glMaterial(GL_FRONT, GL_SHININESS, high_shininess)
|
130
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
131
|
+
glutSolidSphere(1.0, 16, 16)
|
132
|
+
glPopMatrix()
|
133
|
+
|
134
|
+
# draw sphere in first row, fourth column
|
135
|
+
# diffuse reflection emission no ambient or specular reflection
|
136
|
+
glPushMatrix()
|
137
|
+
glTranslate(3.75, 3.0, 0.0)
|
138
|
+
glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
|
139
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
140
|
+
glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
|
141
|
+
glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
|
142
|
+
glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
|
143
|
+
glutSolidSphere(1.0, 16, 16)
|
144
|
+
glPopMatrix()
|
145
|
+
|
146
|
+
# draw sphere in second row, first column
|
147
|
+
# ambient and diffuse reflection no specular
|
148
|
+
glPushMatrix()
|
149
|
+
glTranslate(-3.75, 0.0, 0.0)
|
150
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
|
151
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
152
|
+
glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
|
153
|
+
glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
|
154
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
155
|
+
glutSolidSphere(1.0, 16, 16)
|
156
|
+
glPopMatrix()
|
157
|
+
|
158
|
+
# draw sphere in second row, second column
|
159
|
+
# ambient, diffuse and specular reflection low shininess
|
160
|
+
glPushMatrix()
|
161
|
+
glTranslate(-1.25, 0.0, 0.0)
|
162
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
|
163
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
164
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
165
|
+
glMaterial(GL_FRONT, GL_SHININESS, low_shininess)
|
166
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
167
|
+
glutSolidSphere(1.0, 16, 16)
|
168
|
+
glPopMatrix()
|
169
|
+
|
170
|
+
# draw sphere in second row, third column
|
171
|
+
# ambient, diffuse and specular reflection high shininess
|
172
|
+
glPushMatrix()
|
173
|
+
glTranslate(1.25, 0.0, 0.0)
|
174
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
|
175
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
176
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
177
|
+
glMaterial(GL_FRONT, GL_SHININESS, high_shininess)
|
178
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
179
|
+
glutSolidSphere(1.0, 16, 16)
|
180
|
+
glPopMatrix()
|
181
|
+
|
182
|
+
# draw sphere in second row, fourth column
|
183
|
+
# ambient and diffuse reflection emission no specular
|
184
|
+
glPushMatrix()
|
185
|
+
glTranslate(3.75, 0.0, 0.0)
|
186
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
|
187
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
188
|
+
glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
|
189
|
+
glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
|
190
|
+
glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
|
191
|
+
glutSolidSphere(1.0, 16, 16)
|
192
|
+
glPopMatrix()
|
193
|
+
|
194
|
+
# draw sphere in third row, first column
|
195
|
+
# colored ambient and diffuse reflection no specular
|
196
|
+
glPushMatrix()
|
197
|
+
glTranslate(-3.75, -3.0, 0.0)
|
198
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
|
199
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
200
|
+
glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
|
201
|
+
glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
|
202
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
203
|
+
glutSolidSphere(1.0, 16, 16)
|
204
|
+
glPopMatrix()
|
205
|
+
|
206
|
+
# draw sphere in third row, second column
|
207
|
+
# colored ambient, diffuse and specular reflection low shininess
|
208
|
+
glPushMatrix()
|
209
|
+
glTranslate(-1.25, -3.0, 0.0)
|
210
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
|
211
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
212
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
213
|
+
glMaterial(GL_FRONT, GL_SHININESS, low_shininess)
|
214
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
215
|
+
glutSolidSphere(1.0, 16, 16)
|
216
|
+
glPopMatrix()
|
217
|
+
|
218
|
+
# draw sphere in third row, third column
|
219
|
+
# colored ambient, diffuse and specular reflection high shininess
|
220
|
+
glPushMatrix()
|
221
|
+
glTranslate(1.25, -3.0, 0.0)
|
222
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
|
223
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
224
|
+
glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
|
225
|
+
glMaterial(GL_FRONT, GL_SHININESS, high_shininess)
|
226
|
+
glMaterial(GL_FRONT, GL_EMISSION, no_mat)
|
227
|
+
glutSolidSphere(1.0, 16, 16)
|
228
|
+
glPopMatrix()
|
229
|
+
|
230
|
+
# draw sphere in third row, fourth column
|
231
|
+
# colored ambient and diffuse reflection emission no specular
|
232
|
+
glPushMatrix()
|
233
|
+
glTranslate(3.75, -3.0, 0.0)
|
234
|
+
glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
|
235
|
+
glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
|
236
|
+
glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
|
237
|
+
glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
|
238
|
+
glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
|
239
|
+
glutSolidSphere(1.0, 16, 16)
|
240
|
+
glPopMatrix()
|
241
|
+
|
242
|
+
glutSwapBuffers()
|
241
243
|
end
|
242
244
|
|
243
245
|
myReshape = proc do |w, h|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
246
|
+
glViewport(0, 0, w, h)
|
247
|
+
glMatrixMode(GL_PROJECTION)
|
248
|
+
glLoadIdentity()
|
249
|
+
if (w <= (h * 2))
|
250
|
+
glOrtho(-6.0, 6.0, -3.0*(h.to_f*2)/w, 3.0*(h.to_f*2)/w, -10.0, 10.0)
|
251
|
+
else
|
252
|
+
glOrtho(-6.0*w.to_f/(h*2), 6.0*w.to_f/(h*2), -3.0, 3.0, -10.0, 10.0)
|
253
|
+
end
|
254
|
+
glMatrixMode(GL_MODELVIEW)
|
253
255
|
end
|
254
256
|
|
255
257
|
keyboard = Proc.new do |key, x, y|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
258
|
+
case (key)
|
259
|
+
when ?\e
|
260
|
+
exit(0);
|
261
|
+
end
|
260
262
|
end
|
261
263
|
|
262
264
|
# Main Loop
|
263
|
-
# Open window with initial window size, title bar,
|
265
|
+
# Open window with initial window size, title bar,
|
264
266
|
# RGBA display mode, and handle input events.
|
265
267
|
glutInit()
|
266
268
|
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
|
@@ -272,4 +274,3 @@ glutReshapeFunc(myReshape)
|
|
272
274
|
glutDisplayFunc(display)
|
273
275
|
glutKeyboardFunc(keyboard)
|
274
276
|
glutMainLoop()
|
275
|
-
|