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
@@ -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
|
@@ -40,22 +40,24 @@
|
|
40
40
|
# This program uses evaluators to generate a curved
|
41
41
|
# surface and automatically generated texture coordinates.
|
42
42
|
require 'opengl'
|
43
|
+
require 'glu'
|
44
|
+
require 'glut'
|
43
45
|
include Gl,Glu,Glut
|
44
46
|
|
45
47
|
$ctrlpoints = [
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
[[ -1.5, -1.5, 4.0], [ -0.5, -1.5, 2.0], [0.5, -1.5, -1.0], [1.5, -1.5, 2.0]],
|
49
|
+
[[ -1.5, -0.5, 1.0], [ -0.5, -0.5, 3.0], [0.5, -0.5, 0.0], [1.5, -0.5, -1.0]],
|
50
|
+
[[ -1.5, 0.5, 4.0], [ -0.5, 0.5, 0.0], [0.5, 0.5, 3.0], [1.5, 0.5, 4.0]],
|
51
|
+
[[ -1.5, 1.5, -2.0], [ -0.5, 1.5, -2.0], [0.5, 1.5, 0.0], [1.5, 1.5, -1.0]]
|
50
52
|
].flatten
|
51
53
|
|
52
54
|
$texpts = [[[0.0, 0.0], [0.0, 1.0]], [[1.0, 0.0], [1.0, 1.0]]].flatten
|
53
55
|
|
54
56
|
display = proc do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
58
|
+
glColor(1.0, 1.0, 1.0)
|
59
|
+
glEvalMesh2(GL_FILL, 0, 20, 0, 20)
|
60
|
+
glutSwapBuffers()
|
59
61
|
end
|
60
62
|
|
61
63
|
ImageWidth=64
|
@@ -63,57 +65,57 @@ ImageHeight=64
|
|
63
65
|
$image = []
|
64
66
|
|
65
67
|
def makeImage
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
for i in 0...ImageWidth
|
69
|
+
ti = 2.0*Math::PI*i/ImageWidth.to_f
|
70
|
+
for j in 0...ImageHeight
|
71
|
+
tj = 2.0*Math::PI*j/ImageHeight.to_f
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
$image[3*(ImageHeight*i+j)] = 127*(1.0+Math::sin(ti))
|
74
|
+
$image[3*(ImageHeight*i+j)+1] = 127*(1.0+Math::cos(2*tj))
|
75
|
+
$image[3*(ImageHeight*i+j)+2] = 127*(1.0+Math::cos(ti+tj))
|
76
|
+
end
|
77
|
+
end
|
76
78
|
end
|
77
79
|
|
78
80
|
def myinit
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
81
|
+
glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints)
|
82
|
+
glMap2d(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, $texpts)
|
83
|
+
glEnable(GL_MAP2_TEXTURE_COORD_2)
|
84
|
+
glEnable(GL_MAP2_VERTEX_3)
|
85
|
+
glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
|
86
|
+
makeImage()
|
87
|
+
glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
|
88
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
|
89
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
|
90
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
91
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
92
|
+
glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageWidth, ImageHeight, 0,
|
93
|
+
GL_RGB, GL_UNSIGNED_BYTE, $image.pack("C*"))
|
94
|
+
glEnable(GL_TEXTURE_2D)
|
95
|
+
glEnable(GL_DEPTH_TEST)
|
96
|
+
glEnable(GL_NORMALIZE)
|
97
|
+
glShadeModel(GL_FLAT)
|
96
98
|
end
|
97
99
|
|
98
100
|
myReshape = proc do|w, h|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
101
|
+
glViewport(0, 0, w, h)
|
102
|
+
glMatrixMode(GL_PROJECTION)
|
103
|
+
glLoadIdentity()
|
104
|
+
if (w <= h)
|
105
|
+
glOrtho(-4.0, 4.0, -4.0*h.to_f/w, 4.0*h.to_f/w, -4.0, 4.0)
|
106
|
+
else
|
107
|
+
glOrtho(-4.0*w.to_f/h, 4.0*w.to_f/h, -4.0, 4.0, -4.0, 4.0)
|
108
|
+
end
|
109
|
+
glMatrixMode(GL_MODELVIEW)
|
110
|
+
glLoadIdentity()
|
111
|
+
glRotate(85.0, 1.0, 1.0, 1.0)
|
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()
|
data/examples/RedBook/varray.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
|
@@ -37,6 +37,8 @@
|
|
37
37
|
# varray.c
|
38
38
|
# This program demonstrates vertex arrays.
|
39
39
|
require 'opengl'
|
40
|
+
require 'glu'
|
41
|
+
require 'glut'
|
40
42
|
include Gl,Glu,Glut
|
41
43
|
|
42
44
|
POINTER=1
|
@@ -50,100 +52,100 @@ $setupMethod = POINTER
|
|
50
52
|
$derefMethod = DRAWARRAY
|
51
53
|
|
52
54
|
def setupPointers
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
55
|
+
$vertices = [25, 25,
|
56
|
+
100, 325,
|
57
|
+
175, 25,
|
58
|
+
175, 325,
|
59
|
+
250, 25,
|
60
|
+
325, 325].pack("i*")
|
61
|
+
$colors = [1.0, 0.2, 0.2,
|
62
|
+
0.2, 0.2, 1.0,
|
63
|
+
0.8, 1.0, 0.2,
|
64
|
+
0.75, 0.75, 0.75,
|
65
|
+
0.35, 0.35, 0.35,
|
66
|
+
0.5, 0.5, 0.5].pack("f*")
|
67
|
+
|
68
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
69
|
+
glEnableClientState(GL_COLOR_ARRAY)
|
70
|
+
|
71
|
+
glVertexPointer(2, GL_INT, 0, $vertices)
|
72
|
+
glColorPointer(3, GL_FLOAT, 0, $colors)
|
71
73
|
end
|
72
74
|
|
73
75
|
def setupInterleave
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
$intertwined =
|
77
|
+
[1.0, 0.2, 1.0, 100.0, 100.0, 0.0,
|
78
|
+
1.0, 0.2, 0.2, 0.0, 200.0, 0.0,
|
79
|
+
1.0, 1.0, 0.2, 100.0, 300.0, 0.0,
|
80
|
+
0.2, 1.0, 0.2, 200.0, 300.0, 0.0,
|
81
|
+
0.2, 1.0, 1.0, 300.0, 200.0, 0.0,
|
82
|
+
0.2, 0.2, 1.0, 200.0, 100.0, 0.0].pack("f*")
|
83
|
+
|
84
|
+
glInterleavedArrays(GL_C3F_V3F, 0, $intertwined)
|
83
85
|
end
|
84
86
|
|
85
87
|
def init
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
89
|
+
glShadeModel(GL_SMOOTH)
|
90
|
+
setupPointers()
|
89
91
|
end
|
90
92
|
|
91
93
|
display = proc do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
94
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
95
|
+
if ($derefMethod == DRAWARRAY)
|
96
|
+
glDrawArrays(GL_TRIANGLES, 0, 6)
|
97
|
+
elsif ($derefMethod == ARRAYELEMENT)
|
98
|
+
glBegin(GL_TRIANGLES)
|
99
|
+
glArrayElement(2)
|
100
|
+
glArrayElement(3)
|
101
|
+
glArrayElement(5)
|
102
|
+
glEnd()
|
103
|
+
elsif ($derefMethod == DRAWELEMENTS)
|
104
|
+
$indices = [0, 1, 3, 4].pack("I*")
|
105
|
+
glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, $indices)
|
106
|
+
end
|
107
|
+
glutSwapBuffers()
|
106
108
|
end
|
107
109
|
|
108
110
|
reshape = proc do|w, h|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
111
|
+
glViewport(0, 0, w, h)
|
112
|
+
glMatrixMode(GL_PROJECTION)
|
113
|
+
glLoadIdentity()
|
114
|
+
gluOrtho2D(0.0, w, 0.0, h)
|
113
115
|
end
|
114
116
|
|
115
117
|
mouse = proc do |button, state, x, y|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
118
|
+
case (button)
|
119
|
+
when GLUT_LEFT_BUTTON
|
120
|
+
if (state == GLUT_DOWN)
|
121
|
+
if ($setupMethod == POINTER)
|
122
|
+
$setupMethod = INTERLEAVED
|
123
|
+
setupInterleave()
|
124
|
+
elsif ($setupMethod == INTERLEAVED)
|
125
|
+
$setupMethod = POINTER
|
126
|
+
setupPointers()
|
127
|
+
end
|
128
|
+
glutPostRedisplay()
|
129
|
+
end
|
130
|
+
when GLUT_MIDDLE_BUTTON,GLUT_RIGHT_BUTTON
|
131
|
+
if (state == GLUT_DOWN)
|
132
|
+
if ($derefMethod == DRAWARRAY)
|
133
|
+
$derefMethod = ARRAYELEMENT
|
134
|
+
elsif ($derefMethod == ARRAYELEMENT)
|
135
|
+
$derefMethod = DRAWELEMENTS
|
136
|
+
elsif ($derefMethod == DRAWELEMENTS)
|
137
|
+
$derefMethod = DRAWARRAY
|
138
|
+
end
|
139
|
+
glutPostRedisplay()
|
140
|
+
end
|
141
|
+
end
|
140
142
|
end
|
141
143
|
|
142
144
|
keyboard = proc do |key, x, y|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
145
|
+
case (key)
|
146
|
+
when ?\e
|
147
|
+
exit(0)
|
148
|
+
end
|
147
149
|
end
|
148
150
|
|
149
151
|
glutInit()
|
@@ -152,7 +154,7 @@ glutInitWindowSize(350, 350)
|
|
152
154
|
glutInitWindowPosition(100, 100)
|
153
155
|
glutCreateWindow()
|
154
156
|
init()
|
155
|
-
glutDisplayFunc(display)
|
157
|
+
glutDisplayFunc(display)
|
156
158
|
glutReshapeFunc(reshape)
|
157
159
|
glutMouseFunc(mouse)
|
158
160
|
glutKeyboardFunc(keyboard)
|
data/examples/RedBook/wrap.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,14 +41,16 @@
|
|
41
41
|
# Interaction: Pressing the 's' and 'S' keys switch the
|
42
42
|
# wrapping between clamping and repeating for the s parameter.
|
43
43
|
# The 't' and 'T' keys control the wrapping for the t parameter.
|
44
|
-
#
|
44
|
+
#
|
45
45
|
# If running this program on OpenGL 1.0, texture objects are
|
46
46
|
# not used.
|
47
47
|
require 'opengl'
|
48
|
+
require 'glu'
|
49
|
+
require 'glut'
|
48
50
|
require 'mathn'
|
49
51
|
include Gl,Glu,Glut
|
50
52
|
|
51
|
-
#
|
53
|
+
# Create checkerboard texture
|
52
54
|
CheckImageWidth=64
|
53
55
|
CheckImageHeight=64
|
54
56
|
$checkImage = []
|
@@ -56,84 +58,84 @@ $checkImage = []
|
|
56
58
|
$texName = 0
|
57
59
|
|
58
60
|
def makeCheckImage
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
for i in 0..CheckImageHeight-1
|
62
|
+
for j in 0..CheckImageWidth-1
|
63
|
+
c = if (((i&0x8)==0)!=((j&0x8)==0)) then 255 else 0 end
|
64
|
+
$checkImage[(i*CheckImageWidth+j)*4+0] = c
|
65
|
+
$checkImage[(i*CheckImageWidth+j)*4+1] = c
|
66
|
+
$checkImage[(i*CheckImageWidth+j)*4+2] = c
|
67
|
+
$checkImage[(i*CheckImageWidth+j)*4+3] = 255
|
68
|
+
end
|
69
|
+
end
|
68
70
|
end
|
69
71
|
|
70
72
|
def init
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
73
|
+
glClearColor(0.0, 0.0, 0.0, 0.0)
|
74
|
+
glShadeModel(GL_FLAT)
|
75
|
+
glEnable(GL_DEPTH_TEST)
|
76
|
+
|
77
|
+
makeCheckImage()
|
78
|
+
glPixelStore(GL_UNPACK_ALIGNMENT, 1)
|
79
|
+
|
80
|
+
$texName = glGenTextures(1)
|
81
|
+
glBindTexture(GL_TEXTURE_2D, $texName[0])
|
82
|
+
|
83
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
|
84
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
|
85
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
86
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
87
|
+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth,
|
88
|
+
CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
|
87
89
|
end
|
88
90
|
|
89
91
|
display = Proc.new do
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
92
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
93
|
+
glEnable(GL_TEXTURE_2D)
|
94
|
+
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
|
95
|
+
glBindTexture(GL_TEXTURE_2D, $texName[0])
|
96
|
+
|
97
|
+
glBegin(GL_QUADS)
|
98
|
+
glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
|
99
|
+
glTexCoord(0.0, 3.0); glVertex(-2.0, 1.0, 0.0)
|
100
|
+
glTexCoord(3.0, 3.0); glVertex(0.0, 1.0, 0.0)
|
101
|
+
glTexCoord(3.0, 0.0); glVertex(0.0, -1.0, 0.0)
|
102
|
+
|
103
|
+
glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
|
104
|
+
glTexCoord(0.0, 3.0); glVertex(1.0, 1.0, 0.0)
|
105
|
+
glTexCoord(3.0, 3.0); glVertex(2.41421, 1.0, -1.41421)
|
106
|
+
glTexCoord(3.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
|
107
|
+
glEnd()
|
108
|
+
glutSwapBuffers()
|
109
|
+
glDisable(GL_TEXTURE_2D)
|
108
110
|
end
|
109
111
|
|
110
112
|
reshape = Proc.new do |w, h|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
113
|
+
glViewport(0, 0, w, h)
|
114
|
+
glMatrixMode(GL_PROJECTION)
|
115
|
+
glLoadIdentity()
|
116
|
+
GLU.Perspective(60.0, w/h, 1.0, 30.0)
|
117
|
+
glMatrixMode(GL_MODELVIEW)
|
118
|
+
glLoadIdentity()
|
119
|
+
glTranslate(0.0, 0.0, -3.6)
|
118
120
|
end
|
119
121
|
|
120
122
|
keyboard = Proc.new do |key, x, y|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
123
|
+
case (key)
|
124
|
+
when ?s
|
125
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
|
126
|
+
glutPostRedisplay()
|
127
|
+
when ?S
|
128
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
|
129
|
+
glutPostRedisplay()
|
130
|
+
when ?t
|
131
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
|
132
|
+
glutPostRedisplay()
|
133
|
+
when ?T
|
134
|
+
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
|
135
|
+
glutPostRedisplay()
|
136
|
+
when ?\e
|
137
|
+
exit(0)
|
138
|
+
end
|
137
139
|
end
|
138
140
|
|
139
141
|
glutInit
|